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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Integration with third party using OData and Data entities

(0) ShareShare
ReportReport
Posted on by

Hello all!

I have to develop interfaces for a third party which will GET and POST data to my D365FO. I have chosen Data entities and ODATA for this. Could anyone tell how I will be able to access the request body in X++ code so that I can return the response accordingly. 

Also any resources for the process would help.

Thank you

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,985 Most Valuable Professional on at

    D365FO already handles that for you - it'll read the request, act on it and return the requested data. For example, it'll return record matching given criteria or update a record with provided values.

    You can influence the behevior of an entity by overriding its method or using extensions, but you don't work with low-level concepts such as HTTP message body.

  • Community Member Profile Picture
    on at

    Thanks Martin for the response!

    The third party will send me the parameters and data in the request body in JSON format. Reading your response, this means that I wont be able to read the body? How should the third party send me the data then?

  • Martin Dráb Profile Picture
    237,985 Most Valuable Professional on at

    As I said: if we're talking about data entities accessed through OData, which you claimed above, then it's already supported by D365FO and there is no need for trying to handle requests by yourself.

    Do you want to suggest that the information was wrong and they won't really send OData requests to work with data enties, but some other HTTP requests? If so, please realize that you gave us no information about that so far. You'll have to explain your situation before we can comment on it.

  • Community Member Profile Picture
    on at

    Okay! Let me explain the scenario here.

    I need to create a API endpoint that I will share with the third party. Lets say the URL is https://<base_url>/orders.

    The third party will then send a GET request to the URL and send the JSON data in the body like this

    {

    custCode: "CUST-001",

    currency: "USD"

    }

    I need to read this body and then return the orders for the specified customer in the specified currency like this (in JSON)

    {

    custCode: "CUST-001",

    orders: [

    {

    orderId: "ORDER-001",

    itemId: "ITEM-001"

    },

    {

    orderId: "ORDER-002",

    itemId: "ITEM-002"

    }

    ]

    }

    This is the exact scenario where I need to read the request and respond with the data. Also, I need this scenario to be real time.

  • Verified answer
    Martin Dráb Profile Picture
    237,985 Most Valuable Professional on at

    All right, then you're not talking about OData.

    You have two options:

    1) Change your requirements. Let the integration architect explain the other party how D365FO APIs look like and try to convince them to use these APIs.

    2) Implement your own middle-tier service translating between requests from the third party to requests that can be handled by D365FO (either by OData services or custom services).

  • Community Member Profile Picture
    on at

    Thanks for the help Martin!

    I looked other integration strategies in D365FO and found the Custom services in which we can expose a method as a service endpoint using AIF attributes.

    But then I found that AIF is deprecated from AX 7 and is replaced with DIXF. 

    Can I expose the methods now as a service using DIXF or any other framework available?

  • Martin Dráb Profile Picture
    237,985 Most Valuable Professional on at

    Yes, I mentioned custom services above, but neither custom service meet your requirements about the URL and the message format. If you want to use them, you must adjust your requirements.

    You can learn more about them in D365FO documentation (Custom service development). (It's not AIF.) Also note that OData offer actions, in addition to CRUD operations with entities (more in documentation under Open Data Protocol (OData)).

  • Community Member Profile Picture
    on at

    Thanks for the response Martin. 

    I implemented a sample custom service for testing and that gave me the desired results.

    My only query left is regarding the "$id": "1" in the response object. What exactly is this extra field that is there and how can I remove it? (screenshot attached)

    pastedimage1609941717959v1.png

  • Verified answer
    Martin Dráb Profile Picture
    237,985 Most Valuable Professional on at

    Your response looks wrong to me. Instead of returning structured data in a JSON object, you're returing a mere string value (in the 'data' property). Something must be wrong in your implementation.

    Use a data contract class representing your data. It should have a parm* method with DataMember attribute for each property, such as Amount. You'll return this class from your service operation.

    The class need to be decorated with DataContract attribute, and if you want to get rid off $id, add also Newtonsoft.Json.JsonObjectAttribute(IsReference = false).

  • Community Member Profile Picture
    on at

    Thanks Martin! Newtonsoft.Json.JsonObjectAttribute(IsReference = false) solved the $id issue.

    Regarding the response, as I said this was a sample service for testing, I just returned the input data as a string just to verify the working of the service.

    Thanks anyways!

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 467 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 420 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 241 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans