I'm trying to execute the below in Postman. However, I do not see all the requests getting executed. Only 2 requests get executed i.e. the requests which triggers all the rest and the second one ReadByQuery_PODOCUMENT rest fail to execute.
Thanks in advance for all the help.
postman.setNextRequest('ReadByQuery_PODOCUMENT');
postman.setNextRequest('Read_PODOCUMENTENTRY');
postman.setNextRequest('Create PO Trxn 3.0 - With Deliver to tag at header over ridden');
postman.setNextRequest('ReadByQuery_PODOCUMENT');
postman.setNextRequest('Read_PODOCUMENTENTRY');
postman.setNextRequest('Create PO Trxn 3.0 - With No header Deliver to tag specified');
postman.setNextRequest('ReadByQuery_PODOCUMENT');
postman.setNextRequest('Read_PODOCUMENTENTRY');
That's right - you can add only one postman.setNextRequest()
per request. However, I have managed to execute multiple setNextRequest()
and chain all the requests using multiple if
conditions. Depending on the request name, postman would decide which request to post next.
var jsonData = JSON.parse(responseBody); //Parse JSON responseBody
var req_name = pm.variables.get("request_name"); //Get the requestname
var RECORDNO = pm.environment.set("RECORDNO", jsonData[0].RECORDNO); //Set the record n.o
//TC001 - API 3.0 Verify "Deliver to" at the header is set to blank
if (req_name === "Create_Purchase_Order 3.0 - Deliver to blank") {
pm.test("Verify Header Deliver to is autopopulated with default value", function() {
pm.expect(jsonData[0]["DELIVERTO.CONTACTNAME"]).to.eql("Hal");
postman.setNextRequest('ReadByQuery_PODOCUMENTENTRY');
});
}