2019-01-14 | apurvghai | Dynamics CRM SDK | Postman, General
Postman is the most popular tool today to troubleshoot and write sample code for testing. Postman offers variety of programming options as well. I love to use variables option which is easy to then show the data.
There are different ways to use Postman with Online vs OnPremise system
Setup Postman
Prerequisites
Instructions
Follow these instructions to Post x-www-form-urlencoded. You can use the below parameters
x-www-form-urlencoded
Online: POST https://login.microsoftonline.com/your-azure-tenantid/oauth2/token
OnPremise/IFD: POST https://yourstsurl.yourdomain.com/adfs/ls
Server to Server authentication
grant_type: client_credentials client_id: {client_id} client_secret: {client_secret} resource: {resourceurl}
User Password authentication
grant_type: password client_id: {client id} client_secret: {client_secret} resource: {resourceurl} username: {username} password: {password}
Navigate to Tests tab, paste below code:
var json = JSON.parse(responseBody); postman.setEnvironmentVariable("BearerToken", json.access_token);
On-Premise Approach
OnPremise approach differs but not a lot. Your token URL is now ADFS Url and resource URL becomes your CRM org’s IFD url.
Example: resource: https://yourCRMorg.yourdomain.com
resource: https://yourCRMorg.yourdomain.com
This will return JWT Token which can be decoded from this site and will be stored in your variables.
Important Note Create application user in CRM Online. Follow these instructions
CRM WebAPI Operations
Now that you know how to perform POST or GET Operations. I will now demostrate how to use JWT token and make CRM Web API.
Authorization: Bearer {BearerToken}
Hit send and enjoy your results