Execute request in collection runner after successfully completing first request

I am trying to deploy cloud VM’s using Postman and below is the workflow that I am trying accomplish.

1.) Send request to deploy VM image. (it may take few minutes for the vm to be successfully deployed).
2.) Send another request to check the status of VM deployment , check response for completion.
3.) If response is not completed , send another health check request after 10 seconds, until response contains completed.
4.) If response for above health is successful , execute next request in collection.


Hi @abdulwasay.1218!

You should be able to accomplish this using postman.setNextRequest() and setTimeout().

  1. Send request to deploy VM image
  2. Send request to check completion
  • In pre-request script of this request, include the following to delay 10 seconds if the deployment has been tested previously, and is not finished yet:
    pm.variables.set('timeoutCheck', false);

var timeoutCheck = pm.variables.get('timeoutCheck');

if(timeoutCheck === true)
  • In Test script of this request, include something like the following to check for a success condition, and if not present loop the request again with a 10 second delay
var requestStatus = pm.variables.get('status');

// check for your success condition. Response code 200 is used as an example here.
if (pm.response.code != 200) {
    // indicate that a delay should be used when looping this request again
    // loop this request again
} else if (pm.response.code === 200){
    // proceed to next request

Hope that helps!