web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / My scenario - Integrat...
Finance forum

My scenario - Integration using OData

(1) ShareShare
ReportReport
Posted on by 162

Dear All,

I have created projects as suggested in the below link but in a little different way as follows.

https://github.com/microsoft/Dynamics-AX-Integration/tree/master/ServiceSamples

Step1: Created AuthenticationUtility and ODataUtility projects as per the above link.

Step2: Created Class library which receives multiple sales orders data from third party applications.

Step3: Desrialize the Json response into Objects in C#.

Step4: Created Resources object to connect with D365 Odata using Authentication Utility and Odata utility. And creating the sales orders received from third party application.

Step5; Tested the above class library using Console application and worked fine.

Step6: Now I added all Class library projects into D365 solution and added reference in D365 projects to create batch job which will receive sales order from third party application and insert into D365 FO using OData.

Step7: Here I am facing the below error.

Message: The type initializer for 'GeneratedEdmModel' threw an exception.

InnerException: Method not found: 'Boolean Microsoft.OData.Edm.Csdl.CsdlReader.TryParse(System.Xml.XmlReader, Boolean, Microsoft.OData.Edm.IEdmModel ByRef, System.Collections.Generic.IEnumerable`1<Microsoft.OData.Edm.Validation.EdmError> ByRef)'.

Also, I checked the context object while debugging and it shows the below error.

error CS1705: Assembly 'ODataUtility' with identity 'ODataUtility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'Microsoft.OData.Client, Version=7.6.0.30605, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'Microsoft.OData.Client' with identity 'Microsoft.OData.Client, Version=6.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

I tried to to find the method 'Boolean Microsoft.OData.Edm.Csdl.CsdlReader.TryParse' in Odataclient.cs file. But I could not find it.

Kindly help me how to resolve the issue.

pastedimage1566160969401v1.png

  • Martin Dráb Profile Picture
    240,972 Most Valuable Professional on at

    What are you trying to achieve by your design? OData services are used when other applications want to make requests to F&O. If you're running code inside a batch job class in F&O, you're obviously already in F&Oand therefore you don't need web services to communicate with AX.

    You either want the third party application to call F&O to create sales orders - then let the app call OData services offered by F&O. Or you want a batch fetching data from some other application and save them to F&O database - but then you don't need any OData service nor anything else you described.

  • Ravi Sankar Profile Picture
    162 on at

    Dear Martin,

    We planned to receive sales orders periodically(every 2 hours) from third party applications and creating it in D365 FO. And we receive the data from third party applications in Json format which needs to be converted into objects/fields and mapped with our sales order. Kindly suggest me how to create the sales order in FO which is received in Json format from third party applications.

    Please help to deserialize below Json@C# sample object into x++ data format.

    public class Data
    {
    public List<Item> items { get; set; }
    public SearchCriteria search_criteria { get; set; }
    public int total_count { get; set; }
    //public string customer_id { get; set; }
    }

    public class Item
    {
    public string customer_dob { get; set; }
    public string customer_email { get; set; }
    public string customer_firstname { get; set; }
    public int customer_gender { get; set; }
    public int customer_group_id { get; set; }
    public int customer_is_guest { get; set; }
    public string customer_lastname { get; set; }
    }

    Thanks in advance..

  • Martin Dráb Profile Picture
    240,972 Most Valuable Professional on at

    One option is converting the file to something you can import via Data Management (e.g. XML). Another is using Logic Apps, for example, to parse JSON and passing the data to a data entry through F&O connector. Yet another option is parsing JSON by yourself (as you mentioned), populating a data entity record and calling insert().

    But you should your design from a higher level. Think about which system will initialize the communication, whether you need synchronous communication, what will be the amount of data, what should happen when one of the systems is down and so on. This will help you decide which communication mechanism you should use (direct web service calls, messaging, file exchange) and in which direction.

  • Martin Dráb Profile Picture
    240,972 Most Valuable Professional on at

    By the way, how do you want to create sales orders from the data above? It looks like customer data, not sales order data.

  • Ravi Sankar Profile Picture
    162 on at

    Yeah, I have pasted only customer data available in Sales order data.

    Here is the full sales order data we receive from third party applications.

    public class Item2

    {

       public int amount_refunded { get; set; }

       public int base_amount_refunded { get; set; }

       public int base_discount_amount { get; set; }

       public int base_discount_invoiced { get; set; }

       public int base_discount_tax_compensation_amount { get; set; }

       public int base_original_price { get; set; }

       public int base_price { get; set; }

       public int base_price_incl_tax { get; set; }

       public int base_row_invoiced { get; set; }

       public int base_row_total { get; set; }

       public int base_row_total_incl_tax { get; set; }

       public int base_tax_amount { get; set; }

       public int base_tax_invoiced { get; set; }

       public string created_at { get; set; }

       public int discount_amount { get; set; }

       public int discount_invoiced { get; set; }

       public int discount_percent { get; set; }

       public int free_shipping { get; set; }

       public int discount_tax_compensation_amount { get; set; }

       public int is_qty_decimal { get; set; }

       public int is_virtual { get; set; }

       public int item_id { get; set; }

       public string name { get; set; }

       public int no_discount { get; set; }

       public int order_id { get; set; }

       public int original_price { get; set; }

       public int price { get; set; }

       public int price_incl_tax { get; set; }

       public int product_id { get; set; }

       public string product_type { get; set; }

       public int qty_canceled { get; set; }

       public int qty_invoiced { get; set; }

       public int qty_ordered { get; set; }

       public int qty_refunded { get; set; }

       public int qty_shipped { get; set; }

       public int quote_item_id { get; set; }

       public int row_invoiced { get; set; }

       public int row_total { get; set; }

       public int row_total_incl_tax { get; set; }

       public double row_weight { get; set; }

       public string sku { get; set; }

       public int store_id { get; set; }

       public int tax_amount { get; set; }

       public int tax_invoiced { get; set; }

       public int tax_percent { get; set; }

       public string updated_at { get; set; }

       public double weight { get; set; }

       public int? discount_tax_compensation_canceled { get; set; }

       public int? tax_canceled { get; set; }

    }

    public class BillingAddress

    {

       public string address_type { get; set; }

       public string city { get; set; }

       public string company { get; set; }

       public string country_id { get; set; }

       public int customer_address_id { get; set; }

       public string email { get; set; }

       public int entity_id { get; set; }

       public string fax { get; set; }

       public string firstname { get; set; }

       public string lastname { get; set; }

       public int parent_id { get; set; }

       public string postcode { get; set; }

       public List<string> street { get; set; }

       public string telephone { get; set; }

       public string region { get; set; }

       public string region_code { get; set; }

       public int? region_id { get; set; }

    }

    public class Payment

    {

       public object account_status { get; set; }

       public List<string> additional_information { get; set; }

       public int amount_authorized { get; set; }

       public int amount_ordered { get; set; }

       public int base_amount_authorized { get; set; }

       public int base_amount_ordered { get; set; }

       public int base_shipping_amount { get; set; }

       public string cc_exp_year { get; set; }

       public object cc_last4 { get; set; }

       public string cc_ss_start_month { get; set; }

       public string cc_ss_start_year { get; set; }

       public int entity_id { get; set; }

       public string last_trans_id { get; set; }

       public string method { get; set; }

       public int parent_id { get; set; }

       public int shipping_amount { get; set; }

    }

    public class Item

    {

       public string base_currency_code { get; set; }

       public int base_discount_amount { get; set; }

       public int base_grand_total { get; set; }

       public int base_discount_tax_compensation_amount { get; set; }

       public int base_shipping_amount { get; set; }

       public int base_shipping_discount_amount { get; set; }

       public int base_shipping_discount_tax_compensation_amnt { get; set; }

       public int base_shipping_incl_tax { get; set; }

       public int base_shipping_tax_amount { get; set; }

       public int base_subtotal { get; set; }

       public int base_subtotal_incl_tax { get; set; }

       public int base_tax_amount { get; set; }

       public int base_total_due { get; set; }

       public int base_to_global_rate { get; set; }

       public int base_to_order_rate { get; set; }

       public int billing_address_id { get; set; }

       public string created_at { get; set; }

       public string customer_dob { get; set; }

       public string customer_email { get; set; }

       public string customer_firstname { get; set; }

       public int customer_gender { get; set; }

       public int customer_group_id { get; set; }

       public int customer_is_guest { get; set; }

       public string customer_lastname { get; set; }

       public int customer_note_notify { get; set; }

       public int discount_amount { get; set; }

       public int entity_id { get; set; }

       public string global_currency_code { get; set; }

       public int grand_total { get; set; }

       public int discount_tax_compensation_amount { get; set; }

       public string increment_id { get; set; }

       public int is_virtual { get; set; }

       public string order_currency_code { get; set; }

       public string protect_code { get; set; }

       public int quote_id { get; set; }

       public string remote_ip { get; set; }

       public int shipping_amount { get; set; }

       public string shipping_description { get; set; }

       public int shipping_discount_amount { get; set; }

       public int shipping_discount_tax_compensation_amount { get; set; }

       public int shipping_incl_tax { get; set; }

       public int shipping_tax_amount { get; set; }

       public string state { get; set; }

       public string status { get; set; }

       public string store_currency_code { get; set; }

       public int store_id { get; set; }

       public string store_name { get; set; }

       public int store_to_base_rate { get; set; }

       public int store_to_order_rate { get; set; }

       public int subtotal { get; set; }

       public int subtotal_incl_tax { get; set; }

       public int tax_amount { get; set; }

       public int total_due { get; set; }

       public int total_item_count { get; set; }

       public int total_qty_ordered { get; set; }

       public string updated_at { get; set; }

       public double weight { get; set; }

       public List<Item2> items { get; set; }

       public BillingAddress billing_address { get; set; }

       public Payment payment { get; set; }

       public List<StatusHistory> status_histories { get; set; }

       public ExtensionAttributes extension_attributes { get; set; }

       public int? base_discount_canceled { get; set; }

       public int? base_shipping_canceled { get; set; }

       public int? base_subtotal_canceled { get; set; }

       public int? base_tax_canceled { get; set; }

       public int? base_total_canceled { get; set; }

       public int? discount_canceled { get; set; }

       public int? shipping_canceled { get; set; }

       public int? subtotal_canceled { get; set; }

       public int? tax_canceled { get; set; }

       public int? total_canceled { get; set; }

       public int? customer_id { get; set; }

       public int? email_sent { get; set; }

    }

    public class Data

    {

       public List<Item> items { get; set; }

       public SearchCriteria search_criteria { get; set; }

       public int total_count { get; set; }

    }

    public class RootObject

    {

       public string code { get; set; }

       public string messageCode { get; set; }

       public string description { get; set; }

       public Data data { get; set; }

       public string current_datetime { get; set; }

       public string timezone { get; set; }

    }

    Actually, we are not going to use all data for creating Sales order in D365 FO.

    Do we have an any sample app from your third option(populating a data entity record and calling insert())

  • Martin Dráb Profile Picture
    240,972 Most Valuable Professional on at

    No, I don't have such an application, because we usually use existing integration options instead of writing custom code for it. Nevertheless f you know how to use tables in X++ (assigning field values, calling methods), you should be fine.

    But it seems to me that you stick to a particular technical design that you chose without understanding your options and that you should review the overall approach. Please look at the reply where I mentioned a few things you should consider when making the high-level design.

  • Eisenberk Profile Picture
    87 on at
    Hi,
     
    I am having the same issue. Did you find any solution?
     
    Regards,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans