Unable to run a API multiple times using setNextRequest

I have simple three get APIs. testApi, testApi2 and testApi3
I just want to run 3rd API three times right after the first. Here is the test script:

var i = 0;
while (i<3) {


The problem is the first get API run and get the response then the loop run 3 times but this setnextRequest only one time. WHY? The statement is under the loop then it should run three times. right?




Please help. Let me know if any further info needed.

That is not how setNextRequest works.

All it does is set the next request that will run after ALL of the code in the Tests tab has been executed. You can only have one setNextRequest in your code. If you have more than one, then it will just run the last one.

Therefore in your code it will loop three times straight away, and then run the third API once after the loop has completed.

If you want to hit a third API this way before running a second API, it sounds like you should use sendRequest().

1 Like

Thank You Mike Jones