Here in this post I give hints about how to register an application in Azure Active Directory, set the application access in AX and then how to call AX data entity from Postman
Register an application and give the necessary API Permissions
Based on the information found in the following Microsoft docs, and with the support of our IT manager, I made the setup.
https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app
Azure App registration screens
AX
Go to ‘System administration / Azure Active Directory applications ‘
In Postman
I am using the developer VM that can be downloaded from LCS site (Lifecycle Services), I have installed Postman on this DEV VM and my URL is ’https://usnconeboxax1aos.cloud.onebox.dynamics.com’. I will call data entities like for example the Vendors for which the URL is ’https://usnconeboxax1aos.cloud.onebox.dynamics.com/data/Vendors’.
To prevent getting the following SSL error, you need to modify one setting of Postman.
“Could not get any response
There was an error connecting to https://usnconeboxax1aos.cloud.onebox.dynamics.com/data/Vendors.
Why this might have happened:
• The server couldn’t send a response:
Ensure that the backend is working properly
• Self-signed SSL certificates are being blocked:
Fix this by turning off ‘SSL certificate verification’ in Settings > General
• Proxy configured incorrectly
Ensure that proxy is configured correctly in Settings > Proxy
• Request timeout:
Change request timeout in Settings > General”
Go to Settings and turn off SSL certificate verification,
Environment variable setup
- ’client_id’, ’client_secret’ & ’adid’ come from Azure, from the AAD app registration
- ’appIdUri’ is ’ https://login.microsoftonline.com/common/oauth2/nativeclient’
- ’authCode’ will be generated and updated here in a later step, described below
- ’resource’ is the URL of the local AX: https://usnconeboxax1aos.cloud.onebox.dynamics.com
- ’grant_type’ is ’client_credentials’
Get the access token
To get the access token, set up the following in Postman and click send:
POST – https://login.microsoftonline.com/{{adId}}/oauth2/token
After clicking send you should see something like this (don’t forget to turn SSL verification off as I described above):
Copy the access token and update the ‘authCode’ variable with this long string. Remember that the token has an expiry, so you need to update it later. You could have a look at the values coded in the token (for example the expiry date) if you went to ’jwt.io’. Paste the text into the ’Encoded’ textbox. Move your mouse over the values on the right in the ’Decoded’ box and you will get a readable value.
Access the data entity from Postman
After this many setups, you can call https://usnconeboxax1aos.cloud.onebox.dynamics.com/data/Vendors by creating a get type request like on the screenshot below.
Or without using variable, you can paste the token directly to the ’Authorization’ value box after ’Bearer’ and a space. Click ’send’ and see the result:
You can add a filter parameter for example: