Thoughts on how to move through a collection, but stopping and running x amount of APIs randomly from list of API calls before moving to the next API call

What I am trying to accomplish is…

Postman Collection contains…say 10 total APIs. I would run the first API and once it has the proper response back, it would then move into the loop where it would run x number of times pulling API calls randomly from a predetermined set of API calls. Once this loop has completed, it would move to API call #2 on the main list, and then rinse and repeat.

I’ve somewhat visualized it how it might need to happen, but wondering if anyone has tried something like this before, and might have code example to share.

I’m thinking it would work this way:

  1. After first API call is done, setNextRequest() would move to the folder that has all the API calls that should run randomly.
  2. Ha, step #2 is where I get hung up. I know how I would do this in straight Python, but drawing a blank on how to set this up with Postman’s test. If this is even possible…

Can the setNextRequest() be used on a folder, or does it have to go to an API call?

Thinking maybe a global variable for the x that gets set after each real API call that runs. The folder that has all the random API calls would have a pre-req that would check this variable. There would also need to be a list with all the random API calls that could be used to set the setNextRequest(), and pick those randomly, unless there is a more elegant/easier way.


I have not used the setNextRequest, but I have used a function to make a sendRequest call against a list of values.

see this comment I made - How Can One Terminate Executing a Request From Within Pre-Request Script?