I have a runner set up with just one request. User provides a .csv file and that request is called as many times as there are lines in that .csv file.
During the execution, I am testing if response is anything other than 200, if it is, I want it to stop the run, and exit the runner completely.
I feel it’s needed to emphasize that I don’t want it to just stop with current request, but completely stop the runner and not continue with other itterations.
Most suggested solution online is setNextRequest(null), however this doesn’t stop the run, it just skips all subsequent calls in THIS iteration, but will continue with whatever the next record is, and go until the end.
What I’m currently doing as a stop gap is if response != 200, then I set timeout to 600000 ms and instruct the user to stop the run manually, which is clunky, and brings risks of it’s own.
Any suggestion/workaround is appreciated.
This is what my code looked when I tried using setNextRequest(null) (tested with 401 because it was easiest to reproduce):
if(pm.response.code == 401){
postman.setNextRequest(null);
pm.test(“Token not valid or expired, renew token”,function(){
pm.response.to.have.status(201);
})
}
This is what my implementation looks like now:
if(pm.response.code == 401){
pm.test(“Token not valid or expired, renew token. Click Stop run and Get token.”,function(){
pm.response.to.have.status(201);
});
setTimeout(() => {}, 600000);
}