I am working on an api testing. In first POST request, I am fetching some files from csv and running all the files and getting an associated runids. In next GET request, I want to iterate through all the ids and test their status on another end point. Then, there is one more GET request where I need to iterate through the runds and get another status.
I tried using single collection, but there requests are run one by one and not all iterations per request. I want to get all the iterations for first POST request and then all for remaining two GET requests individually.
Have a look at the following post, which may achieve what you are attempting to do. The logic will be similar for doing what you need.
However, Iโm not quite following your logic here.
Sounds like you should get a single run ID at a time, which would then enable the two following GET requests to follow in order without you having to create loops in code. Can you format your CSV file so there is one runID on each line? So the test runner can handle the loop.
Thanks. But, I want to chain environment variable from POST request to the two GET requests. Requirement is like this. All the files will be posted to POST end and get runids in return. These ids will be stored in an environment variable in the form of array. Then access these array elements one by one in two of the successive GET methods and get the status accordingly.
Thanks. I am trying to run a csv file which contains name of a files to be posted through POST request. In return I get unique ids for each of the files. When, I get these ids, I have to check two statuses about them on two other GET requests.
It uses a pre-request script to retrieve your stored array.
The pre-request script uses the JavaScript array.shift() function which returns the first element and also importantly deletes that first element from the array.
You then write the first element to a new collection variable to use in the actual request, and also update the array variable stored which will now have one less entry.
In the tests tab of the actual request. You have a tiny bit of code that checks the length of the array and uses the Postman setNextRequest function to keep running the same request if the array is larger than zero. (The pre-request will keep triggering and will keep removing the first item in the array until there are no more entries).
Note: setNextRequest only works from the Postman runner.