Configure Postman for Media Services REST API calls

This article shows you how to configure Postman so it can be used to call Azure Media Services (AMS) REST APIs. The article shows how to import environment and collection files into Postman. The collection contains grouped definitions of HTTP requests that call Azure Media Services (AMS) REST APIs. The environment file contains variables that are used by the collection.

Before you start developing, review Developing with Media Services v3 APIs.

Prerequisites

  • Create a Media Services account. Make sure to remember the resource group name and the Media Services account name.

  • Get information needed to access APIs

  • Install the Postman REST client to execute the REST APIs shown in some of the AMS REST tutorials.

    We are using Postman but any REST tool would be suitable. Other alternatives are: Visual Studio Code with the REST plugin or Telerik Fiddler.

Important

Review naming conventions.

Download Postman files

Clone a GitHub repository that contains the Postman collection and environment files.

git clone https://github.com/Azure-Samples/media-services-v3-rest-postman.git

Configure Postman

Configure the environment

  1. Open the Postman app.

  2. On the right of the screen, select the Manage environment option.

    Manage env

  3. From the Manage environment dialog, click Import.

  4. Browse to the Azure Media Service v3 Environment.postman_environment.json file that was downloaded when you cloned https://github.com/Azure-Samples/media-services-v3-rest-postman.git.

  5. The Azure Media Service v3 Environment environment is added.

    Note

    Update access variables with values you got from the Access the Media Services API section above.

  6. Double-click on the selected file and enter values that you got by following the accessing API steps.

  7. Close the dialog.

  8. Select the Azure Media Service v3 Environment environment from the dropdown.

    Choose env

Configure the collection

  1. Click Import to import the collection file.

  2. Browse to the Media Services v3.postman_collection.json file that was downloaded when you cloned https://github.com/Azure-Samples/media-services-v3-rest-postman.git

  3. Choose the Media Services v3.postman_collection.json file.

    Import a file

Get Azure AD Token

Before you start manipulating AMS v3 resources you need to get and set Azure AD Token for Service Principal Authentication.

  1. In the left window of the Postman app, select "Step 1: Get AAD Auth token".

  2. Then, select "Get Azure AD Token for Service Principal Authentication".

  3. Press Send.

    The following POST operation is sent.

    https://login.microsoftonline.com/:tenantId/oauth2/token
    
  4. The response comes back with the token and sets the "AccessToken" environment variable to the token value.

    Get AAD token

Troubleshooting

  • If your application fails with "HTTP 504: Gateway Timeout", make sure that the location variable has not been explicitly set to a value other than the expected location of the Media Services account.
  • If you get an "account not found" error, also check to make sure that the location property in the Body JSON message is set to the location that the Media Services account is in.

See also

Next steps