Automation batch script


I want to create a script that gets the response from a youtube api request, take a field from that response and make a new POST request to another API, eg:

  1. GET{CHANNELID}&eventType=live&type=video&key={APIKEY}
  2. Copy [items[id[videoId]]] from GET response

Can this be done with Postman?

Hi @diplatis, welcome to the community! :wave:

I think you can do this with the help of the test scripts in Postman and the feature called pm.sendRequest in the Tests script tab in the app.

What you have to do is use the below script and craft it according to your requirement and then make the custom request based on the response of the initial GET request.

Sample code to refer:

const videoId = _.get(pm.response.json(),  ''),
  customRequest = {
    url: `${videoId}`,
      method: 'POST',
      header: {
        'Accept': 'application / json',
        'Content - Type': 'application / x - www - form - urlencoded'

      body: {
        mode: 'urlencoded',
        urlencoded: [
            key: "grant_type",
            value: "urn:ibm:params:oauth:grant-type:iam-auth"

pm.sendRequest(customRequest, function (err, res) {
 // handle the response or the error, you can even add more test cases based on this current response