0

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');

Collection Folder File Structure screenshot

Nakini
  • 772
  • 1
  • 8
  • 19
Jonathan Vaz
  • 21
  • 1
  • 3
  • Where have you added these? In a single request? Need more information about the implementation. – Danny Dainton May 17 '18 at 15:17
  • This has all been added in a single request. What I'm try to achieve here is instead of creating multiple requests I'm trying to reuse the 'ReadByQuery_PODOCUMENT' and 'Read_PODOCUMENTENTRY' after every 'Create PO Trxn 3.0'. – Jonathan Vaz May 18 '18 at 06:05
  • I'm sure that you can only add `one` per request - Have you seen any documentation or proved that you can add multiple `setNextRequest()` to the same request and successfully run these? – Danny Dainton May 18 '18 at 10:53

1 Answers1

1

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');
    });
} 
Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Jonathan Vaz
  • 21
  • 1
  • 3