I have two API calls in the same collection. I got a list of alerts from my previous API call. Now in my second API call, I want to use each alert from the list to get more information on it. Now this is where I am facing a problem, the second API call keeps on picking the first element of the list and doesn’t go through each element.
I tried the ‘Shift’ function and for loop, but both are not working.
Here is my code:
1st API script
Get {{URL}}/alerts-list
Tests
a = JSON.parse(responseBody)
pm.collectionVariables.set("ID", a);
=> got a list of alerts here successfully in collection variable ID
2nd API script - detail
Get {{URL}}/alerts-info/{{alertIDnow}}/
Pre-request scripts
const Aid = pm.collectionVariables.get("ID")
pm.collectionVariables.set("alertIDnow", Aid.shift());
postman.setNextRequest('detail');
=> detail is the name of the 2nd API script. When using a collection runner it only fetches the first element from the Aid list and doesn’t iterate through the list.
Please help me out. I am using Postman web application. Been stuck on this for days.