Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

postman setNextRequest not executing

I have this postman logic:

var returnData = JSON.parse(responseBody);
tests["status code"] = (responseCode.code === 401);
if (responseCode.code === 401) {
    postman.setNextRequest("get token with good login");
}

Even though status code is 401, that "setNextRequest" never get executed.
I am new to postman so maybe I am making a mistake somewhere?

Appreciate any pointer as to how I can chain this test and have it go onto to the next one?

thanks

-vincent

like image 707
Vince Yau Avatar asked Oct 12 '16 17:10

Vince Yau


People also ask

How do I enable runner in Postman?

Step1 − Click on the Runner menu in Postman. Step2 − The Collection Runner window shall open up. Step3 − Choose the name of the Collection from Choose a collection or folder. Step4 − Select an Environment from the Environment field.

How do you loop API calls in Postman?

In Postman, we can also work on branching and looping. We can branch and loop across API requests with the help of setNextRequest() function. This function is used to set the request to be executed next. This function takes one argument, i.e., the name of the request, which will execute next.

What is the execution flow in Postman?

POSTMAN workflow is the order of request execution within a collection. When you run the collection directly, then the requests are either executed randomly or executed serially.


1 Answers

I figured out what's wrong. I need to run the sequences in "Runner". I was merely pressing "Send" beforehand.
Thanks for your reply.

like image 193
Vince Yau Avatar answered Sep 20 '22 14:09

Vince Yau