1

I'm trying to use Postman to verify an API. I can verify the single request without any issues, and get the desired output. However, I want to now do a load test, and run the same call 5 times.

I tried using a for and while loop, but Postman gives an error.

while i < 5
{
   "FirstName": "TestFN",
   "LastName": "TestLN",
   "orderID": *I want to update this based on the value of i --> "Concat(100,i)"*
}
Hemant Rathi
  • 59
  • 1
  • 6
  • I think [this](https://stackoverflow.com/questions/36157105/postman-how-to-make-multiple-requests-at-the-same-time) could answer your question. – pușigreen Jul 16 '21 at 19:26

1 Answers1

0

in pre-reqeust add :

let count = pm.variables.get("count") ? pm.variables.get("count") : 5

if(count-1){
   count -= 1
   postman.setNextRequest(pm.info.requestName)
   pm.variables.set("count",count)
}else{
  // if you don't want to execute remaining
  //postman.setNextRequest(null)
}

this will run the request 5 times when run using newman or collection runner as @Danny mentioned in comment

PDHide
  • 18,113
  • 2
  • 31
  • 46
  • 2
    They would need to be using the Collection Runner for that to work. It looks like they were trying to do that in a single request and expecting it to send the request multiple times. – Danny Dainton Jul 16 '21 at 21:35