Set up a Postman environment

You can use Postman to connect to your Common Data Service 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 your Common Data Service 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 with Postman variables, see Postman Documentation > Variables.

Prerequisites

Connect with your Common Data Service environment

This environment uses a client ID for an application that is registered for all Common Data Service environments.

You can use the clientid and callback values supplied in these instructions. However, when building your own application, you should register your own Azure Active Directory (Azure AD) application.

To register your own Azure AD application, see the steps described in Walkthrough: Register a Common Data Service app with Azure Active Directory.

Use these steps to create a Postman environment that you can use to connect with your Common Data Service 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}}

    Note

    For relevance search, specify a version of 1.0 and a webapiurl of {{url}}/api/search/v{{version}}/.

    Create a new Postman environment to connect with Online instance

  2. Replace the instance URL placeholder value with the URL of your Common Data Service 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 Common Data Service 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.

Test your connection

Create a new Web API request to test the connection with your Common Data Service 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
Walkthrough: Register a Common Data Service app with Azure Active Directory