Skip to content Skip to sidebar Skip to footer

Postman Form Data Bug File Upload Stale Reference

In this topic, you will larn how to set up the popular Postman HTTP client to brand requests to the Brightcove RESTful APIs. Although you tin utilise ringlet statements on the command line to make requests, in that location are several apps that provide you UI and features to make this easier. This certificate volition bear witness you how to use one such tool, the Postman app. Note: this totorial was written for Postman 9.six.2 - if yous see discrepancies with the current version, please use the Feedback link on the right beneath to let u.s. know.

Install Postman

Get Postman from postman.com. In that location is an online version you can use, merely we recommend installing the desktop app.

Get customer credentials

To work with the Brightcove APIs, you volition need customer credentials for the account and API(south) you wish to use. Go you lot client credentials in Studio by following the directions in Managing API Authentication Credentials. In the steps below, nosotros will be making CMS API requests using Postman, so your credentials should have at least the post-obit permissions:

  • Video: Read/Write

Y'all can add equally many additional permissions as you like to go 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 lot like.

You tin employ this online app if y'all prefer. If you do, you lot demand to specify at to the lowest degree video-cloud/video/all permissions.

Get the OpenAPI spec

Although non required, yous tin greatly simplify the setup of Postman is to import the OpenAPI specification for the API y'all want to use. You can do this for whatsoever of the Brightcove platform APIs, but for this tutorial, nosotros'll use the CMS API.

To get the OpenAPI spec, simply become to the CMS API Reference and click the Download button:

Download OpenAPI Spec
Download OpenAPI Spec

The downloaded file will exist chosen openapi.yaml

Import the OpenAPI Spec

The adjacent step is to launch the Postman app, then import the OpenAPI spec that you downloaded:

Open the Collection

As the API is imported, Postman will generate a collection of requests.

  1. Click Collections.
  2. Select the new CMS API drove:
  3. Expand the collection and click on the videos folder and select the Get Videos asking.
    CMS API Collection
    CMS API Drove
    Request Details
    Request Details

Notice that Postman has set upwards almost of the details for you from the API reference, including the request itself and the params that tin be added to information technology. It also provides the documentation for the parameters, let's you edit values, and uncheck the ones you practice not wish to send with the request.

You will still need to supply some data of your own, nevertheless, including the account id and authentication information. You lot can practice this on a request by request basis, merely the better way is to create an environment for the request, where you can store normally used information equally variables. We will do that in the next section.

Create an environs

The steps below will walk you through setting upwards an environment for the CMS API requests

  1. Click the Environment Quick Look icon, and so Add together:
    Create Environment
    Create Environment
  2. Edit the environment proper name, changing it to "Brightcove APIs" (you will exist able to use this environs for other Brightcove APIs every bit well, adding new variables to it as necessary).
    Edit Enviroment Name
    Edit Enviroment Proper noun
  3. Click the text "Add a new variable", type in account_id, and so click in the INITIAL VALUE field and enter your Video Cloud account id (and then do the same for CURRENT VALUE):
    Enter Variable
    Enter Variable
  4. Repeat the previous step to add boosted variables:
    Environment Variables
    Variable Initial Value
    client_id (your client id - run across Get Client Credentials above)
    client_secret (your client clandestine - meet Go Client Credentials above)
    access_token_url https://oauth.brightcove.com/v4/access_token
  5. Click Save to save the environs:
    Save Environment
    Relieve Environment
  6. Become dorsum to your Brightcove CMS API drove and select the surround you created from the environment selector:
    Environment Selector
    Environment Selector

Surround variables can exist referenced by enclosing them in double curly braces - case: {{client_id}}. Postman helps you lot with auto-completion when you type "{{...". Y'all can endeavour this by going back to the Get Videos asking and first typing "{{a" in the Value field for the Path Variable account_id:

Variable Autocompletion
Variable Autocompletion

Enable requests

Now that you accept the environment set up, you tin utilize the variables to test requests. We will wait at the Get Videos asking offset.

  1. If you did not already do then, enter {{account_id}} for the value of the account_id Path Variable.
  2. Click the Authorization tab for the request:
    Auth Tab
    Auth Tab
  3. Under Configuration Options, change the Grant Blazon to Client-Credentials:
    Auth Grant Type
    Auth Grant Type
  4. Enter the post-obit variables from your environs in the appropriate fields:
    • Admission Token URL: {{access_token_url}}
    • Client ID: {{client_id}}
    • Client Secret: {{client_secret}}
  5. Click Get New Access Token:
    Authorization Setup
    Authorization Setup
  6. When the dominance is complete, yous can click Proceed or wait for the token to appear. And so click Employ Token:
    Manage Access Tokens
    Manage Access Tokens

Note that Brightcove access tokens expire afterwards five minutes. Depending on what you are doing and how quickly, you may be able to use the same access token several times. When it expires, the CMS API will render an unauthorized mistake:

            [ 	{ 			"error_code": "UNAUTHORIZED", 			"message": "Permission denied." 	} ]          

(The exact form of the message may vary for other APIs, only it volition exist similar.)

When this happens, but return to the Authorization tab and asking a new token. Yous should also delete any expired tokens to avoid confusion, as they are of no further value.

Delete Expired Tokens
Delete Expired Tokens

Brand requests

Yous are now prepare to brand a Get Videos asking.

  1. Become back to the Params tab and uncheck all the Query Params (you lot can utilise them, of course, and change the values, simply nosotros volition but use the default values for this first examination).
  2. Click Send.
  3. You should run into JSON code appear in the response area below (an array of video metadata objects):
    Response Data
    Response Data
  4. Now we will try a write request (Create Video). Select that request in the collection:
    Create Video Request
    Create Video Request
  5. You lot will over again demand to enter for the Account ID Path Variable. Yous will NOT demand echo the steps in the previous section to set up authorization, because Postman transfers these settings to other requests in the drove. Withal, you will still need to generate a new access token.
  6. Next, become to the Body tab, where yous volition encounter a sample request body from the API reference:
    Sample Request Body
    Sample Request Body
  7. This JSON is editable. The but required field for a Create Video request is the proper noun, so change that value to "Test Video" and remove the rest of the JSON so that your asking body is:
                    { 	"name": "Test video" }              
  8. At present click send (getting a new admission token if you need one), and you should come across the metadata object for the new video announced in the response surface area.
  • Testing Tools for Brightcove APIs
  • Hallmark for API Requests
  • Online API Tester
  • Use Insomnia for API Requests

snoddycitionabous77.blogspot.com

Source: https://apis.support.brightcove.com/general/use-postman-api-requests.html

Post a Comment for "Postman Form Data Bug File Upload Stale Reference"