When using Postman's Collection Runner and reading a csv file - I have two requests: A Get, and a Put. These requests are in their own folder and it's that folder that I'm kicking off Collection Runner from.
The response from the Get simply returns either true or false.
The Put Request flips this to false and that's it. So I thought it'd be easy enough:
var jsonInfo = pm.response.json();
console.log(data["AppId"] + " = " + jsonInfo);
if (jsonInfo === true)
{
console.log("Setting " + data["AppId"] + " to false.");
postman.setNextRequest("Change-AppID-Decision-to-False");
}
Because I don't want the Put to run all the time, when using Collection Runner I have the Put unchecked. The Get kicks off, and I know it gets into the body of the if statement as it writes the statement to the console but the Put never runs after the Get request.
I'll concede that I could just run the Put since all the appId's that run through here need to be set to false but for my own knowledge I'm wondering if this is possible because it feels like it should be a simple and useful thing that Postman should be able to do :). Thoughts?
Because I don't want the Put to run all the time, when using Collection Runner I have the Put unchecked.
That does not work, as only checked Requests are considered by Postman Run.
But the fix should be as easy at to terminate the run:
postman.setNextRequest(null)
So your code should look like:
var jsonInfo = pm.response.json();
console.log(data["AppId"] + " = " + jsonInfo);
if (jsonInfo === true)
{
console.log("Setting " + data["AppId"] + " to false.");
postman.setNextRequest("Change-AppID-Decision-to-False");
} else {
console.log("Nothing to do now");
postman.setNextRequest(null)
}