Using Postman with Dynamics 365 Online and OnPremise

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

  1. Setup Postman

    • Download Postman
    • Create an environment, let’s say CrmOnline. See instructions
    • Once you’ve your environment setup, it’s time to create variables. See instructions
  2. Prerequisites

    • Setup your application Id in Azure (Type: WebApp/WebAPI)
    • Assign permissions to Dynamics CRM Online - Delegated Permissions
  3. Instructions

    Follow these instructions to Post x-www-form-urlencoded. You can use the below parameters

    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

      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.

      • Select GET Operation
      • Use this URL: https://demo.crm.dynamics.com/data/api/v9.1/WhoAmI
      • In the Headers tab, write the following
      • Use Bulk edit option

      Authorization: Bearer {BearerToken}

      Hit send and enjoy your results


Recent Posts
Getting started with Dynamics 365 CRM SDK in C#
Jan 14, 19 | Dynamics CRM SDK
Using Postman with Dynamics 365 Online and OnPremise
Jan 14, 19 | Dynamics CRM SDK
Getting Started with WebAPI
Dec 28, 18 | Dynamics CRM SDK