Set up a Postman environment

You can use Postman to connect to your Dynamics 365 for Customer Engagement apps instance and to compose Web API requests, send them, and view responses. Managing authentication challenges many people. This topic describes how to configure a Postman environment to work for both online and on-premises environments.

You can use a Postman environment to save a set of variables that you use to connect. These values can be accessed within Postman by using this syntax: {{name}}. For more information about Postman variables, see Postman Documentation > Variables.

Prerequisites

Select the connection option that works for your environment:

Connect with an online environment

Note

This environment uses a client ID for an application that is registered for all Dynamics 365 for Customer Engagement apps online environments. You must register your application using the steps described in Walkthrough: Register a Dynamics 365 for Customer Engagement app with Azure Active Directory.

Use these steps to create a Postman environment that you can use to connect with your Dynamics 365 for Customer Engagement apps (online) instance:

  1. Launch the Postman desktop application.
  2. Select the Environment Options gear icon in the top-right corner.
  3. In the Manage Environments dialog box, select the Add button to add a new environment.

Click on Add button to add a new Postman environment

  1. In the dialog box that opens, type a name for the environment. Then add the following key-value pairs into the editing space.

    Variable name Value
    url https://<add your environment name, like ‘myorg.crm’>.dynamics.com
    clientid 51f81489-12ee-4a9e-aaae-a2591f45987d
    version 9.0
    webapiurl {{url}}/api/data/v{{version}}/
    callback https://callbackurl
    authurl https://login.microsoftonline.com/common/oauth2/authorize?resource={{url}}

    Create a new Postman environment to connect with Online instance

  2. Replace the instance URL placeholder value with the URL of your Dynamics 365 for Customer Engagement apps instance, and select Add to save the environment.

  3. Close the Manage environments dialog box.

Generate an access token to use with your environment

To connect using OAuth 2.0, you must have an access token. Use the following steps to get a new access token:

  1. Make sure the new environment you created is selected.

  2. Select the Authorization tab.

  3. Set the Type to OAuth 2.0.

  4. Verify that you have selected the environment that you created.

  5. Select Get New Access Token

    In Authorization tab, set Type to OAuth 2.0

  6. Set the following values in the dialog box. Select Implicit from the Grant Type drop-down menu. You can set the Token Name to whatever you like, and leave other keys set to default values.

    Get new Access Token

    Note

    If you are configuring environments in Postman for multiple Dynamics 365 for Customer Engagement apps instances using different user credentials, you might need to delete the cookies cached by Postman. Select the Cookies link, which can be found under the Send button, and remove the saved cookies from the Manage Cookies dialog box.
    Remove Cookies
    Some of these cookies are very persistent. You can delete some of them in groups, but you might have to delete others individually. You might need to do this twice to ensure that no cookies remain.

  7. Select Request Token. When you do this, an Azure Active Directory sign-in page appears. Enter your username and password.

  8. After the token is generated, scroll to the bottom and select Use Token. This closes the Manage Access Tokens dialog box.

  9. After you have added a token, you can select which token to apply to requests. On the Available Tokens drop-down list, select the token you have just created. The Authorization header gets added to the Web API request.

See Test your connection for steps to verify your connection.

Connect with an on-premises environment

  1. Launch the Postman desktop application.
  2. Select the Environment Options gear icon in the top-right corner.
  3. In the Manage Environments dialog box, select the Add button to add a new environment.
  4. In the dialog box that opens, add a name for the environment. Then copy the following key-value pairs into the editing space.
Variable Name Value
url http://yourservername/yourorgname
version 8.2
webapiurl {{url}}/api/data/v{{version}}/

Create a new Postman environment to connect with On-premise instance

  1. Replace the instance URL placeholder value with your Dynamics 365 for Customer Engagement apps instance URL, and select Add to save the environment.
  2. Close the Manage environments dialog box.

Set credentials

  1. On the Authorization tab, select NTLM Authentication [Beta].
  2. Set the following values in the form:
    Username. Type the alias only; do not include the domain.
    Password. You have the option to show the password.
    Domain. You must set this if you are accessing the account from a different domain, although you can set it to ~ so that the default domain of the server is used.

Your authentication might look like this if you are logging in as an administrator.

Click on Authorization tab, and select NTLM Authentication

Test your connection

Create a new Web API request to test the connection with your Dynamics 365 for Customer Engagement apps instance. Use the WhoAmI function:

  1. Select GET as the HTTP method and add {{webapiurl}}WhoAmI in the editing space. WhoAmI function request
  2. Select Send to send this request.
  3. If your request is successful, you see the data from the WhoAmIResponse ComplexType that is returned by the WhoAmI Function.

See also

Use Postman to perform operations
Use the Dynamics 365 for Customer Engagement Web API
Walkthrough: Register a Dynamics 365 for Customer Engagement app with Azure Active Directory