HOW TO CONNECT TO DYNAMICS 365 ENVIRONMENT USING POSTMAN TO DO WEBAPI CALLS
As a developer, you normally use Console Application, JavaScript, or plugins in XrmtoolBox
in order to test specific requests to make sure they are working as expected.
However, and since the introduction of the Web API in Dynamics 365, there are some tools that you can use to consume the needed WEB API requests
against Dynamics 365 environment.
My preferred tool to use is Postman, and this is our topic today where we will learn how to connect Postman to Dynamics 365 environment
and consume the desired operations like create, update... in order to quickly test and accomplish them.
- First, you have to create an App Registration in Azure and enable its options as explained in this post to be able to connect to Dynamics 365 environment through Postman using the OAUTH authentication
- Open Postman, and go to the Environments menu, create a new Environment
-
The environment will contain the different variables that will be used to connect to the Dynamics 365 environment
- url: This is the URL of the Dynamics 365 environment
- clientid: This is Application (Client Id) generated when you created the App Registration in Azure (check the above link)
- version: This is the version of the Dynamics 365 API target
- discourl: This is the discovery URL of the dynamics 365 environment with the following format : {{url}}/api/discovery/v{{version}}/
- callback: This is the callback URL you set when you created the App Registration in Azure (check the above link)
- authurl: This is the authorization URL of you dynamics 365 environment with the following format : https://login.microsoftonline.com/common/oauth2/authorize?resource={{url}}
- Once you create the needed variables, go to Collections menu and create new collection that will contain the WEB API requests
- In the new collection, add a new GET request to the dynamics 365 API URL that has the following format: https://<ORGURL>/api/data/v9.2/
-
Within the request page, go to the Authorization tab and set its properties as follow in order to enter the variables for the connection:
- Type: AOUTH 2.0
- Add authorization data to: Request Headers
- Callback URL: This is the callback variable you created previously
- Auth URL: This is the authurl variable you created previously
- Client ID: This is the clientid variable you created previously
-
Once you finish setting the properties, you have to get an access token that will be used to authorize the connection to the environment
-
Click Get New Access Token button
- Sign-in to your account
-
Once the Authentication is completed, click Proceed
-
The Access token will be generated and can be used. Click Use Token
-
The token is copied to the authorization section
-
Click Get New Access Token button
-
Once the token is generated, you can test different API requests against the Dynamics 365 target environment
-
Get the metadata of the Dynamics 365 environment
-
Execute the WhoAmI request and get the user information
-
Get the Account entity names
-
Get the Account entity MetadataId which is the Guid of the entity in the system from the EntityDefinitions
-
Create account records in Dynamics 365
- Create and Manage Polymorphic Lookup Attribute as detailed in this post
-
Get the metadata of the Dynamics 365 environment
Hope This Helps!
Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for the informative post. download Postman
ReplyDelete