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.

In order to generate client credentials you must have Admin permissions for the Brightcove account, or get someone in your organization who has Admin permissions to generate the credentials for you.

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

Launch the Postman app.

Create a new request:
Create New Request

In the new request dialog, enter "Get Players" for the Request Name:
Request Name

Find the Player Management API collection in the list on the left and click it to open your new request:
Player Management API Collection

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

Click Get New Access Token:
Get New Access Token

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

Click Request Token

You should see a new access token appear:
New Access Token

For each request you make, you will need to select an access token to use:

Select Access Token

Your token will expire after 5 minutes. When it does, your API requests will return an Unauthorized error. When that happens, just click Get New Access Token again. Postman will remember all the information you entered into the dialog before, so you won't have to enter it again. Don't forget you need to select the appropriate token from the Available Tokens list after you create a new one.

Since old tokens are of no value, you'll probably want to keep the list clean by deleting old tokens when you create new ones:

Manage TokensDelete Token

Send GET request

Now we are ready to make API requests.

Make a GET request

Now enter the following URL into the Enter request URL field, substituting your account id for {account_id}:

The response should look something like this:
GET ResponseIf you get an Unauthorized error, remember that you may need to get a new access token.

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

Duplicate your Get Players request:
Duplicate Request

Open your new request and rename it "Create Player"
Rename Request

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

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

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

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"
}

Click Send.
If you have recently submitted a request you may not be asked to authenticate again. If you get an Unauthorized error, request a new access token and click Send again.

Your response will look similar to the following (You can click the Pretty button for more nicely formatted JSON):

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 .

Click the gear menu in the top-right Postman and select Manage Environments.Environments Menu

In the Manage Environments dialog, click Add to add an environment.

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

Click Add to add the environment

Close the Manage Environments dialog to return to Postman and select your environment from the menu.
Select an Environment

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