Share This Post

D365 Updates

D365 F&O Testing Services Using Postman

This article explains about D365 F&O Testing Services Using Postman. Microsoft provides sample code for consuming services for Microsoft Dynamics 365 for Finance and Operations. However, there are numerous scenarios where the other endpoint in an integration might not use a Microsoft stack.

Even when the other endpoint does use, for example, the Open Data Protocol (OData) client code that Microsoft makes available, you might find it useful to perform the following actions:

  • Explore and analyze how an interaction’s messages are constructed.
  • Test the response of a service to a well known request.
  • Decide how exceptions will appear to the other endpoint.

Many frequently used tools that will help you perform these actions are available. This topic is not an endorsement of any tool. Although it provides examples that use some frequently used software utilities, the principles should broadly apply to other, similar tools.

D365 F&O Testing Services Using Postman Prerequisites

Before you can test a service by using an external application, you must register the application in Microsoft Azure and in Finance and Operations.

Query Finance and Operations OData by Using Postman

Postman ( is a tool that is often used to interact with RESTful services (such as OData) in scenarios that involve the development and testing of application programming interfaces (APIs). This D365 F&O Testing Services Using Postman procedure is not an endorsement of Postman and other similar tools are available.

However, we are using D365 F&O Testing Services Using Postman to demonstrate the concepts and messages that are involved when you utilize OAuth to authenticate with Azure AD and then make OData requests to and receive responses from MS Dynamics 365 for Finance and Operations.

  • Start Postman.
  • In the upper right corner, choose the gear button and then click Manage environments to create or update an environment.
  • Enter a name for the environment and then choose Bulk Edit.
  • Enter the key value pairs as shown in the following table. Enter one pair per line, and separate the key and value by using a colon (:).
Key Value
tenant_id The Azure tenant ID that you looked up during the setup of prerequisites
client_id The Azure AD application ID that you registered during the setup of prerequisites
client_secret The secret key that you generated during application registration during the setup of prerequisites
grant_type client_credentials
resource The base URL of the Finance and Operations instance without the trailing ‘/’
  • To verify that the key-value pairs can be parsed correctly, select Key-Value Edit and review the results.
  • Close the environment page.
  • In the field to the left of the gear and eye buttons, select the new or updated environment.
  • To retrieve an Azure AD token, create a POST request that has a URL in the format[tenant ID]/oauth2/token.

You can use a URL parameter that refers to the tenant_id environment variable, such as

  • On the Body tab, add body elements as request parameters that refer to the environment variables that you created earlier. Select Bulk Edit, enter the keys from the previous table, enter a colon (:) and then enter the key name again but enclose it in double braces ({{}}). Enter one request parameter per line.
  • On the Tests tab, create a test that validates that the response is reasonable and that stores the returned authorization token in an environment variable. For example.

var json = JSON.parse(responseBody);
tests[“Get Azure AD Token”] = !json.error && responseBody !== ” && responseBody !== ‘{}’ && json.access_token !== ”;
postman.setEnvironmentVariable(“bearerToken”, json.access_token);

  • Select Save, enter a name and collection for the request, and then select Save again.
  • Select Send to make the authorization request. The Body tab should now contain an Azure AD token together with other response details.
  • Because of the test code, the token is now in an environment variable. You can see that the token is an environment variable by choosing the Environment quick look button.
  • Create a request to perform create, read, update or delete (CRUD) operations on the desired data entity using the OData service. Create the URL according to your requirements. You might find it useful to parameterize the request by using a variable that is stored in the environment, as shown earlier.

The following D365 F&O Testing Services Using Postman example of a GET query utilizes a Customer Account parameter. The Microsoft Dynamics 365 F&O query returns name and address details for the customer account that is specified in the environment variable. Note that special characters must be correctly URL-encoded.

https://[Finance and Operations instance URL]/data/Customers?$format=json&$filter=CustomerAccount%20eq%20%27{{custAccount}}%27&$select=CustomerAccount,Name,AddressDescription,FullPrimaryAddress

  • Add an Authorization header that refers to the authorization token that was retrieved earlier and stored in the bearerToken environment variable. The token in the header must be prefixed by Bearer.
  • Create a test to help validate the response. The following example tests that non-empty, JSON-formatted data is returned in the response body.

var json = JSON.parse(responseBody);
tests[“Get customer info”] = !json.error && responseBody !== ” && responseBody !== ‘{}’;

  • Save and send the request and then confirm the result.

In our example, we have now successfully authenticated and then used the OData service to read a customer record. For more information on Microsoft D365 F&O Testing Services Using Postman, please contact us.

Share This Post

Leave a Reply

Notify of
Skip to toolbar