Hello
In Pre-request Script tab I set a few variables, based on the REST API answers (pm.sendRequest()).
For some situation the error is returned, so I cannot continue next iterations.
How can I stop all future steps, whole Collection Runner? On Tests tab I’ve tried set postman.setNextRequest(null) but it does not work. Can I do this from Pre-request Script?
This How to stop Collection Runner on error? does not work for me.
@dracorp without your code as an example, it is hard to say why it did not work.
But notice in the example from the post you reference, the steps are contained within the same pm.test node. The node will perform everything in sequence, and it will only set the postman.setNextRequest(); after a successful 200 status. If 200 status fails, then the next request is still null and it stops.
Based on what you mention, does your ( pm.sendRequest() ) node contain the setting of the variables after success? or are those contained in a separate request node?
(It is also possible that this requires a certain version if postman?? I am on version 7.32.0
pm.test(“Status code is 200”, function () {
postman.setNextRequest(null);
pm.response.to.have.status(200);
postman.setNextRequest();
//convert to json format
var RespData = xml2Json(responseBody);
//set environment level variable
pm.environment.set(“PolicyNumber”, RespData[‘OnlineData.autoSaveDataRs’][’$’][‘policyNumber’]);
//return policy number in test tab
pm.test(pm.environment.get(“PolicyNumber”));
});
Hi @kclausing and @kevin.swiber
It, throw new Error, stops Pre-request Script but not the whole collection. Tests are omitted.
This is good but not enough.