Branching requests from within a script and calling requests with parameter returned from previous response

Hi there,

I’m struggling with postman collection branching scripts.

I have three tests that I need to run.

  1. Login
  2. Get a Bookshelf of that user
  3. Get the course content of that bookshelf
  4. Get the levels of the course content from step 3 request

This is what I have

  1. Login
  2. GetBookShelf
  3. GetCourseData
  4. GetCourseDatawithLevelID

As you can see the parameters are being passed through each request. Request 2 extracts {{ProjectID}}, Request 3 needs {{ProjectID}} to extract {{LevelID}} content. Is there a way to do this, by storing and capturing variables within Request calls?

I’m struggling with 2nd and 3rd request.

For request: GetBookShelf, the JSON body response returns more than one ProjectIds for some Login users. I would like to store that ProjectID in a variable, eg: ProjectID_1, ProjectID_2, ProjectID_3, etc… as I’ve done here:

On the GetCourseData request, I’m iterating through total categories, to loop and return the CategoryIds (same as LevelIds for the next request), I’d like to store these Category IDs in a variable

Once I get the LevelIDs and its ProjectIDs in local variables, I’d like to call the same request with another parameter being passed into the request url, i.e. the LevelID.

What is the best approach to call these requests with the parameters being retrieved from JSON response and variables set? any help appreciated.

Many thanks,


Before iterating over multiple courses / levels, I would just store the data in a nested array, where, for example, the key can be the projectId.

You can then iterate over the array and once you are done, remove the item from the array.

You can use a collection variable to store the array.

Hi @vdespa,

Thanks for that, logic makes sense, getting it implemented is a challenge.

Do you have an example of a Collection Array, that variables can be added and removed?



Here is a collection showing how to manipulate arrays:

It is not very complex, but the may idea is explained in this tutorial:

Thank you! that’s exactly what I was looking for, will give this a try, using that tutorial.