Not getting correct response status when creating multiple sending request from Test

I am trying to send multiple request under one test. But I can see that if first request has status 422 then second request also showing the same status 422 when i am checking it from pm.response.to.have.status(…). Whereas the second request has status 409 and it is sending the correct request. And if I put pm.response.to.have.status(409) for second request it is showing fail. I have printed the responseCode.code in console the output is 409.

Are you using the collection runner or newman? Or are you sending a single request?

Note that postman.setNextRequest() only works with the collection runner and Newman where the intent is to run a collection, as opposed to sending a single request. https://learning.getpostman.com/docs/postman/collection_runs/building_workflows/

Hi!

If I understand correctly, you are trying to run a series of requests inside the Postman application.

The correct way to do this is to use pm.setNextRequest() in the test script.

Two things:

  1. The seNextRequest will ONLY work in collection runner or Newman, just like @lvaltierra said above.

  2. The name that you are to supply is the name of the request YOU provide to the request, for example the name of the request you have in your case is “Multiple Request2”.

Also, try to keep one request per tab, as that is the correct way. The collection runner exists for this purpose. I suggest you check this out for more clarity: Collections in Postman