support Contact Support | system status System Status
Page Contents

    Use Postman for API Requests

    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.0 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 player 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):

      POST Response
      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

    Create a collection from an API reference

    As of version 6.7.4, Postman supports the import of OpenAPI specs to create request collections. Since Brightcove's platform API References are based on the OpenAPI spec, you can use this feature the generate a full collection of requests for any of the Brightcove APIs.

    In the steps below, we will use the Dynamic Ingest API as an example, but the procedure will work for any of the Brightcove platform APIs (not for Player API or the mobiles SDKs, because Postman only supports REST APIs).

    Steps

    1. In your browser, go to Dynamic Ingest API Reference
    2. Click on the Download button under the title to download the OpenAPI specification for the API:
      Download OpenAPI Specification
      Download OpenAPI Specification
    3. Depending on which browser you are using, the specification (a YAML file) may download or open in a new browser tab. If it opens in the browser, either copy and paste the contents into a text file, or save the page source to your local drive. The file should be named openapi.yaml.
    4. Now go to Postman and click the Import button at top of the window on the left side:
      Postman Import Button
      Postman Import Button
    5. Drag and drop the openapi.yaml file from your file manager into the import modal that opens:
      Postman Import Modal
      Postman Import Modal
    6. After Postman processes the file, you will see a new Collection in the list titled Dynamic Ingest API Reference
      New Postman Collection
      New Postman Collection
    7. Drilldown into the folders through accounts/{account id}/video/{video id} and you will see the requests:
      Drilldown to Requests
      Drilldown to Requests
    8. Select the POST request to open it. You will find both the Params and the Body pre-populated from the API reference, but you will need to replace placeholders that show the data type with actual data:
      Prepopulated Params
      Prepopulated Params
      Prepopulated Body
      Prepopulated Body
    9. Once you have replaced the placeholders with appropriate values, you can use the request just like ones you created yourself.

    Page last updated on 20 Mar 2020