I have a collection of requests in POSTMAN. I wanted to add a pause between 2 requests but I couldn't find a way to do so from reading their docs. Any idea?
UPDATE I only wanted to put a pause after one request instead of after every request in the collection.
You can also run collections multiple times against different data sets to build workflows. Delay - An interval delay in milliseconds between each request.
Request Timeout in ms - Enter how long (in milliseconds) Postman will wait for a response before timing out. If you enter 0, Postman will wait for a response forever. Max response size in MB - Enter the largest response size (in megabytes) that Postman will download.
If you have workflows where you need to issue a single request n number of times, you would want to use postman. setNextRequest() , with the argument set to the name of the current request. This will cause Postman to execute the same request again.
In case someone is still looking for this - You can add delay after/before 1 of many test in a collection you can use:
setTimeout(function(){}, [number]);
where 'number' is the milliseconds. If it's added at 'Tests' it will be executed after request is send. If it's added at 'pre-request tests' it will be executed before request is send.
Using javascript's busy wait is a good hack but it makes your CPU hot and the app unresponsive. I figured out this solution using postman-echo.
Assuming you want to add a long delay between Request_A and Request_B.
First, in Request_A's test script set up an env var to mark the start.
environment.delayTimerStart = new Date();
Then, create a GET request in the creation (here called 'Delay 10s'). It makes a GET on https://postman-echo.com/delay/10 (It returns after 10s)
In its test script, add
var curDate = new Date(); if (curDate - environment.delayTimerStart < delay_time_in_sec*1000) { postman.setNextRequest('Delay 10s'); } else { postman.setNextRequest("Request_B"); }
In this way you can add a delay of any length.
Note: 10 sec is the maxium value that postman-echo accepts. If you just need a short delay, simply GET https://postman-echo.com/delay/[1~10].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With