Re-send the same request not working

Hello experts !, I’m trying to mimic a scenario where the end-user accidentally clicks the button twice & request is sent twice !!

try to achieve: sending the same request again after checking the response code.

problem/issue : the console.log within the “if block” gets printed but it seems that the same request is NOT send …

my (simple) logic example in Post-response:

if(pm.response.code == '404') {
    console.log('resending !!');
    pm.execution.setNextRequest(pm.info.requestName);
    console.log('sent')
}

so basically, the console logs are just printed but it seems the Postman is NOT setting the next request to itself …

can someone please rectify my logic here?

Hey @koustubh24 :wave:t2:

Are you using the Collection Runner to do that as that setNextRequest function would only work with that.

This wouldn’t work for an individual request.

Use the pm.execution.setNextRequest() function when running a collection with the Collection Runner, the Postman CLI, or Newman. It has no effect when you run a request using Send .

@danny-dainton , thank you for that insight as I had no idea :grinning:. I intend to use it in “Collection Runner” but for testing the logic I was doing in the “individual request”. Will keep that in mind, thank you again !