Dynamics 365 finance and operations OData Posting using Postman tool

In recent times, OData is being used heavily for reading/writing operations. And testing the data entities is a crucial step to finding the entity behavior with different data payloads.

OData is a standard protocol for creating and consuming data.

There are many tools available to test these CRUD (create, update, delete) operations. Recently I used Postman and found it very handy and easy to use provided all configurations are in-place. Prior to using Postman, I extensively used Fiddler but it requires manual steps. I found Postman more useful compared to Fiddler.

Microsoft has a very useful article about setting up Postman to test data entities – https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/data-entities/third-party-service-test

Assuming you have downloaded the postman desktop application for Windows-64bit and installed it appropriately.
It will ask you to sign in. I used a Gmail account to sign in.

The high level process steps are –

1. POST to a URL to generate access token.
2. Use generated access token for the CRUD operation.


NOTE: Click to the image to see enlarged version. Thumbnail images are shown on the page, and they are not quite obvious or clear.



Step 1A – Create an environment and variables to hold environment related values.



Left section contains all the F&O environments. Each environment configuration holds following information against a variable, and then variable is being referenced during POST or GET Commands.


Two columns exist in here.
Initial value:default values for the environment, if column current value has no values. If Current Value column has information available, then it will be used during execution.

Step 1B – POST to a URL to generate access token.

Green dots are tabs where you will find some information related to the environments that you must configure for successful post and generation of access token.


Since I have multiple environments and each one has different values for variables: client_id, secret and resource url, before running this step, I need to choose correct environment. It is highlighted in the red rectangle in below image.



Click Send button next to the URL to execute the POST operation. And if authentication is successful, then the generated output will look like this.
Important values to check are –
  • Response type: 200 OK
  • Output type: JSON
  • Body section – in JSON format. And for POST operation, access_token is required field.



    NOTE: POST Login API, that is generating the access_token, has body section and it has javascript that is setting the environment variable bearerToken with the value generated by this POST operation and the value of access_token automatically.
    Now I have to do my actual GET operation for the selection environment.



  • Intention – Get me Sales order lines using CDS Sales order lines V2 data entity from the selected environment/url based on the parameters provided.
  • Define parameters in Params section. Define Key/value pair combinations as listed.
  • Click Send button
  • Postman will reach out to the URL and will generate the output in the Body section. As you can see, the response code in blue rectangle is 503 Service unavailable. It means website is not running. Connect to the box and reset IIS from command prompt (run as administrator), type iisreset and hit ENTER. This will restart the box and website should be accessible after 1-2 mins.
  • Try again after 1-2 minutes.
  • Steps: first run the POST Login Operation to generate the new access_token, and then second run the GET operation.

    Get Operation request/response may take some time to return the result because environment URL was originally not accessible, so F&O begins caching operations behind the scene which slows down the response generation process for couple of minutes.





    Points to ponder

  • Response: 200 OK. This is HTTP Response. List of HTTP Response codes can be found here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
  • Response time: For this get operation, as indicated, took 1 minute 46 seconds, but generally responses are quick and typically in milliseconds.

    POST (insert operation) and errors and interpretations

    Scenario: Authentication is successful, however, operation failed with error:

  • 400 bad request: scroll all the way down to the message inner exception. Something like this: “internalexception”: { “message”: “The property ‘CURRENCYCODE’ does not exist on type ‘Microsoft.Dynamics.DataEntities.CDSSalesOrderLineV2’. Make sure to only use property names that are defined by the type.”, “type”: “System.InvalidOperationException”, “stacktrace”: ” at Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataEntityDeserializer.ReadODataBody[T](HttpRequestMessage request)” }

    Issue & Solution:
    Because the field is in CAPITAL form, so change it to CurrencyCode instead of CURRENCYCODE. And run the POST operation again. But you will get another error.

  • 403 Forbidden: It means the intended operation is not allowed. Check inner message.
    “innererror”: { “message”: “insert not allowed for field ‘CurrencyCode'”, “type”: “Microsoft.Dynamics.Platform.Integration.Services.OData.ODataSecurityException”, “stacktrace”: ” at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.UpdateProcessor.CreateEntity_Save(ChangeOperationContext context, ChangeInfo changeInfo)\r\n at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.UpdateManager.c__DisplayClass10_0.b__1(ChangeOperationContext context)\r\n at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.ChangeInfo.ExecuteActionsInCompanyContext(IEnumerable`1 actionList, ChangeOperationContext operationContext)\r\n at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.ChangeInfo.TrySave(ChangeOperationContext operationContext)\r\n at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.UpdateManager.SaveChanges()\r\n at Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataDelegatingHandler.d__3.MoveNext()” }
    Issue & Solution:
    Remove the added “CurrencyCode” field from the Body, and try again. And this time it should be successful with HTTP response code 201 Created.






    Environments: F&O: Update49, version: 10.0.25
    POSTMAN: v9.18.2
  • About Atul Shukla

    Dynamics AX 365 for Operations based data migrations, synchronous and asynchronous integrations, extending data entities and customizing entities for data migrations and integrations. I am into Microsoft Dynamics AX 2012 data migration using SQL Server and DIXF framework. SharePoint is my part time passion where I get involved in designing of SharePoint Branding, Designing and challenging website issues where I then involve and brush up my troubleshooting skills using PowerShell. The blog has articles about the issues that I face randomly followed by the fixes. SharePoint 2010 works pretty differently when it integrates with Dynamics AX 2012/2009, BizTalk EDI Processes. Dynamics AX Reporting is also interesting so I do SSRS installation, configuration for Enterprise Portal and Role centers. Pretty interesting stuff - keeping me engaged all the time.
    This entry was posted in Data Entity, Dynamics AX 365 for operations, OData Protocol and tagged , . Bookmark the permalink.

    Leave a comment