Use Postman for API Requests

Product(s)
Video Cloud
Role(s)
API Developer
Topic(s)
Developer Concepts/Tools
API(s)
Analytics API
Audience API
CMS API
Delivery System API
Dynamic Ingest API
Ingest Profiles API
Live API
OAuth API
Player Management API
Policy API

In this topic, you will learn how to set up the popular Postman HTTP client to make requests to the Brightcove RESTful APIs. Some find curl statements and the command line, used for most of the examples in this section of the documentation, difficult and intimidating. For those, there are numerous tools to send HTTP requests to REST-based services, which include most of the Brightcove APIs. This document will show you how to use one such tool, the Postman app.

Install Postman

Get Postman from www.getpostman.com. Postman can be installed as a Chrome or Mac app. We recommend getting the desktop client, but the Chrome version will run on any platform and is identical in functionality and appearance.

Get client credentials

To work with the Brightcove APIs, you will need client credentials for the account and API(s) you wish to use. Get you client credentials in Studio by following the directions in Managing API Authentication Credentials. In the steps below, we will be making Player Management API requests using Postman, so your credentials should have at least the following permissions:

  • Players: Read/Write

You can add as many additional permissions as you like to get credentials that will be usable for a wider range of API requests. Also note that you get credentials that will work for multiple accounts if you like.

You can use this online app if you prefer. If you do, you need to specify at least video-cloud/player/all permissions.

Using Postman

Once you have your client credentials, you are ready to start using Postman. The steps below will walk you through making some Player Management API requests using Postman.

Setting up Postman to get access tokens

  1. Launch the Postman app.
  2. Create a new request:
    Create New Request
    Create New Request
  3. In the new request dialog, enter "Get Players" for the Request Name:
    Request Name
    Request Name
  4. Click Create Collection, and then enter "Player Management API" for the collection name:
    Create Request Collection
    Create Request Collection
  5. Save the collection.
  6. Find the Player Management API collection in the list on the left and click it to open your new request:
    Player Management API Collection
    Player Management API Collection
  7. Go to the Authorization tab, choose OAuth 2.o as the type, and make sure that Add authorization data to Request Headers is selected:
    Authorization Section
    Authorization Section
  8. Click Get New Access Token:
    Get New Access Token
    Get New Access Token
  9. In the dialog, enter the following information:
    • Token name: Player Management API
    • Grant Type: Client Credentials
    • Access Token URL: https://oauth.brightcove.com/v4/access_token
    • Client ID: (enter your client id)
    • Client Secret: (enter your client secret)
    • Scope: (leave blank)
    • Client Authentication: Send client credentials in body
    Get Access Token Dialog
    Get Access Token Dialog
  10. Click Request Token
  11. You should see a new access token appear:
    New Access Token
    New Access Token

Send GET request

Now we are ready to make API requests.

Make a GET request

  1. Now enter the following URL into the Enter request URL field, substituting your account id for {account_id}:
    https://players.api.brightcove.com/v2/accounts/YOUR_ACCOUNT_ID/players
    
    
    Enter Request URL
    Enter Request URL
  2. Leave the method as GET, and click Send:
    Get Request
    GET Request
  3. The response should look something like this:
    GET Response
    GET Response

Send POST request

Now we will send a POST request with some data. In this case we will create a new video object using the Player Management API.

Make a POST request

  1. Duplicate your Get Players request:
    Duplicate Request
    Duplicate Request
  2. Open your new request and rename it "Create Player"
    Rename Request
    Rename Request
  3. Use the same URL as you did for the GET request steps above, but now choose POST to be the selected HTTP method.
    Post Request
    POST Request
  4. Click the Body tab just under the URL, then choose the raw radio button and JSON (application/json) from the type dropdown menu:
    Request Body
    Request Body
  5. You may note that a new Header gets automatically added to the request. Requests that send data need a header telling the API what kind of data is being sent. Click the Headers tab to see the Content-Type: application/json header:
    Add Header
    Add Header
  6. For the raw data, enter the following JSON code for the body (the screenshot following the JSON shows how the request should appear):
    {
      "name": "Postman Test Player"
    }
    
  7. Click Send.
  8. Your response will look similar to the following (You can click the Pretty button for more nicely formatted JSON):

    <code class=POST Response" src="//learning-services-media.brightcove.com/doc-assets/node/17919-use-postman-http-requests/node17919-create-player-response.png" />
    POST Response
  9. You can verify that your player was created by checking in the Players section of Studio.

Environment variables

Although you can create client credentials for multiple accounts and any combination of API operations, you may wish to maintain greater security by limiting the scope of your credentials to a single account and API (or even specific API operations). If so, you can take advantage of Postman's environment variables to simplify testing requests across multiple accounts and APIs. The key is to set up environments corresponding to each set of client credentials that you use.

Below are the steps for creating and using environment variables for the client_id and client_secret .

  1. Click the gear menu in the top-right Postman and select Manage Environments.
    Environments Menu
    Environments Menu
  2. In the Manage Environments dialog, click Add to add an environment.
  3. For the new environment, enter:
    • A name (Brightcove APIS, or whatever you like)
    • An environment variable called account_id with a value of your account id
    • An environment variable called client_id with a value of your client id
    • An environment variable called client_secret with a value of your client secret
    Add Environment Variables
    Add Environment Variables
  4. Click Add to add the environment
  5. Close the Manage Environments dialog to return to Postman and select your environment from the menu.
    Select an Enviroment
    Select an Environment
  6. Now you can start replacing hard-coded values in your requests with variables. To do so, just type {{ anywhere, and a dropdown list of variables will appear:
    Use Environment Variables
    Use Environment Variables