Canada
pawan.deep55@gmail.com

How to use POSTMAN to access D365FO Odata endpoint

How to use POSTMAN to access D365FO Odata endpoint

Time needed: 10 minutes.

Steps

  1. Start Postman -> manage environments

    Select Manage environments to create or update an environment.
    Enter a name for the environment, and then select Bulk Edit

  2. Bulk edit

    Enter key-value pairs as shown in the below image. Enter one pair per line, and separate the key and value by using a colon (:)
    Following things need to be added
    a) tenant_id – Check under azure active directory to Azure portal
    b) client_id – created during app registration on Azure active directory
    c) client_secret – created in certificate & secrets section
    d) grant_type – enter value as client_credentials
    e) resource – enter D365FO environment URL (note it should not end with /)

    Postman Bulk Edit odata

  3. New POST request

    URL –https://login.microsoftonline.com/:tenant_id/
    oauth2/token

    Enter Environment keys shown in the below image to get access token which will be used in the Odata query authentication.PostRquestForAccessToken

  4. Go to Tests Tab

    On the Tests tab, create a test that validates that the response is reasonable, and then stores the returned authorization token in an environment variable named bearerToken
    ——————————————————————————-
    var json = JSON.parse(responseBody);
    tests[“Get Azure AD Token”] = !json.error && responseBody !== ” && responseBody !== ‘{}’ && json.access_token !== ”;
    postman.setEnvironmentVariable(“bearerToken”, json.access_token);
    —————————————————————————–

    TestsTab

  5. New GET request
    URL – https://YourD365URL.com/data/EntityName

    We need to create Authorization key in header whose value will be ‘Bearer {{bearerToken}}’
    We have used the environment variable created in the previous step to store the token value.
    Hit the send button and voila you have the GET response from the D365FO environment.

    GETRequestD365FOOdata

I hope this article helped you learn how to use POSTMAN to access D365FO Odata endpoint in D365 Finance & operations AX. Don’t forget to share this article. You may also want to see our article on How to do string left or right padding in X++. You can follow us on facebook for more tips and tricks.


Author: Pawan Deep SinghI am a D365 Finance & Operations Technical Consultant. I have dedicated this blog to write about all D365FO , ax2012 x++ related tips and tricks I came across in my career. For any query feel free to contact me via the contact section.

 

Comments: 10

  1. Yogyata Narula says:

    Amazing blog.. Very well written

  2. Keval Solanki says:

    Very nice blog and simple explanation, thank you.
    just to add if no data returned then you can add cross-company=true parameter in request as in my case default was set as “DAT”

  3. Yash Jain says:

    I was able to generate the token successfully but while consuming Odata it is giving 401(Unauthorized) error even though i have registered the application in D365

  4. BRUNO CASTAGNETTI says:

    I have the same problem good token, but error 401 when consuming Odata.
    I have registered the application in D365FO ActiveDiectory parameters, for and Admin User.

    And register on Azure portal permissions for Microsoft API after select Dynamics ERP and delegated permission permissions, for AX, CustomService, Odata..

    Is there an authorization to dataserve for the dataEntity?
    I checked the logs in the VM, nothing. No activity is happening.

    With fidler2.com to explore http exchange i have this error :
    under RFC2616, HTTP/401 reponse will not be cached regardless of what caching headers may be present.
    etc…

    My reference :
    https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/data-entities/third-party-service-test
    https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app

  5. Mark Anderson says:

    I’m puzzled. What is “Get Azure AD Token”
    Ho do I get the main requests to call the request to get a new access token

  6. Mike says:

    All the setup done but hit the error: “error_description”: “AADSTS500011: The resource principal named https://*.com was not found in the tenant named Dell Technologies. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You might have sent your authentication request to the wrong tenant.\r\nTrace ID: 72f31c6c-44af-4ca6-9649-0ab8e1053e00\r\nCorrelation ID: 6745f854-a554-4eed-9b92-2a95da5b7068\r\nTimestamp: 2022-08-31 09:01:53Z”.

  7. JS says:

    Why do I get Error: unable to verify the first certificate when I try to send post request to my vm deployed FinOps solution e.g. https://ffff.cloud.onebox.dynamics.com/data/CustomersV2

  8. Prabhakaran says:

    Can I able to do the actions related to account payable and receivable in d365 finance.

Add your comment