In this article, lets see how to connect and test Dynamics 365 Web API requests using Postman tool, step by step along with troubleshooting steps.

Note: Refer article for steps to connect to Dataverse Web API from Postman tool.

Those who are not familiar with Postman tool, it is a request composer tool, which allows you to authenticate to your Dynamics 365 instance,  compose Web API requests, send them, and view response. Link to download

Prerequisites:

  • Download Postman tool
  • Dynamics 365 online instance. (Subscribe to 30 days trial, if you have not one)
  • Azure Active Directory Portal (You need to login with your Office 365 Credentials)

Register App in Azure Active Directory:

As a first step, you need to register an App in Azure Active Directory (i.e., oAuth) by following below steps

  • Connect to the Azure Active Directory (AD) Portal with your Office 365 credentials.
  • Register a new Dynamics 365 App by following steps mentioned here
  • Once you are done with App registration, copy ‘Application ID’ and ‘Home page’ values, which you need to use next steps.

PostMan_14

Setup your Postman tool:

Create ‘Environment’

  • Create a new Postman ‘Environment’ with below variables. This is one time activity for a single D365 instance.
    • url : Your Dynamics 365 URL
    • clientid : ‘Application ID’ from Azure AD,  generated in above section.
    • version : Dynamics version
    • webapiurl : Set this to {{url}}/api/data/v{{version}}/
    • callback : ‘Home page’ value from Azure AD,  generated in above section.
    • authurl : Set this to https://login.microsoftonline.com/common/oauth2/authorize?resource={{url}}
  • I created a new ‘Environment’ with name ‘DynamicsCRM’ and it looks as below

PostMan_13

Generate oAuth Access Token:

Post ‘Environment’ creation, we need to generate oAuth Access Token. This is one time activity for a single D365 instance.

  • Make sure you select ‘Environment’ created in previous section. In my case its ‘DynamicsCRM’.
  • Under ‘Authorization’ tab, set ‘Type’ to ‘oAuth 2.0’ and click on ‘Get New Access Token’.

PostMan_15

  • In the ‘GET NEW ACCESS TOKEN SCREEN’ make sure you set values as below.

PostMan_1

  • Click ‘Request Token’ and system will prompt you for credentials, pass your O365 credentials.

PostMan_2

  • When you click ‘Next’, you may encounter “response_type ‘token’ is not enabled for the application” exception.
    • To fix this, make sure in your Azure AD Application’s manifest “oauth2AllowImplicitFlow” property is set to ‘true’

PostMan_4

  • You may also encounter “The reply url specified in the request does not match the reply urls configured for the application“.
    • To fix this, make sure you set the Postman’s ‘Environment’ -> ‘callback’ variable set correctly.
  • Click ‘Continue’ to complete the ‘Access Token’ generation process.
  • On successful ‘Access Token’ generation, you would get the screen as below.

PostMan_8

  • Click ‘Use Token’.

That’s it! we are done with settings and its time to test the Dynamics API’s with Postman

Test by executing ‘WhoAmI’ request:

  • Make sure you select the right ‘Environment’ and generated your ‘Access Token’.
  • Select ‘GET’ operation and set the URL as {{webapiurl}}WhoAmI
  • Click ‘Send’
  • You should get “200 OK” response up on success.

PostMan_10

  • You may get “401 Unauthorized” response.

PostMan_11

  • To fix this, make sure you set “Add authorization data to” to “Request Headers”.

PostMan_12

🙂

Advertisements
Advertisements

14 responses to “[Step by Step] Postman tool to test Dynamics 365 online Web API”

  1. arafattehsin Avatar

    This is one of the finest guides I have seen on Postman. Thank you so much Rajeev.

    1. Rajeev Pentyala Avatar

      Glad that it helped you

  2. D 365 Development – Different ways to connect/authenticate Dynamics 365 | Rajeev Pentyala - Dynamics 365 Blog Avatar

    […] With Postman tool you can connect to Web API and perform operations. Refer article […]

  3. tinselworldindia Avatar

    Excellent guide. Well written

  4. Matt R Avatar
    Matt R

    Followed all the steps but when I Request Token and enter my credentials, I just get back access_denied in the Postman console, no other reason.

    1. Matt Rinkenberger Avatar
      Matt Rinkenberger

      Might’ve had some typos, getting a token now, then I chose Use Token and submitted the request, getting 401 unauthorized. Confirmed Add authorization data to Request Headers is selected

  5. Chris Avatar
    Chris

    I followed all your instructions but still getting 500 Internal Server Error in the end. Please help.

  6. Jim Novak Avatar

    excellent – exactly what I needed!

  7. Sam Avatar
    Sam

    Amazing article, it worked like a charm for my crm api. No issues, simply followed the steps and wallah!!

  8. binnyy Avatar

    this helped me, but how to download a report from dynamics using api through postman. I’m able to get the report definition but not the data.Can you guide me.

  9. MB Avatar
    MB

    excellent documentation – followed till the last, after the 401 error changed the auth type, now i get error 500? anything i am doing wrong?

  10. RF Avatar
    RF

    Hello, I’m getting a 403 Forbidden when i do a Get request. What am i doing wrong? Please help me.

  11. Jeff Avatar
    Jeff

    Thank you a ton. One more bit of info would be that using postman 8, you can specify the callback url as https://oauth.pstmn.io/v1/callback. Just remember to add that in your app registration in Azure AD.

  12. [Step by Step] Postman tool with Microsoft Dataverse Web API | Rajeev Pentyala - Microsoft Power Platform Avatar

    […] of years ago, I’ve blogged Postman tool using Dynamics 365 online. In this article, lets go through the steps to connect […]

Leave a reply to D 365 Development – Different ways to connect/authenticate Dynamics 365 | Rajeev Pentyala – Dynamics 365 Blog Cancel reply