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 –
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.
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
POST (insert operation) and errors and interpretations
Scenario: Authentication is successful, however, operation failed with error: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.“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