Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable collection pre-request script at request level

I have a test collection in postman. I have a pre-request script to be run at the Collection level, but there are specific requests in the collection where I'd like the pre-request script not to run.

How can I achieve this?

like image 542
89f3a1c Avatar asked Jul 22 '26 01:07

89f3a1c


1 Answers

You cannot do it, but as a workaround just add a condition for collection script like:

if (pm.info.requestName !== "the request you want to skip") {

}

If you want to do it dynamically, then you have to do it from the request running before the request you want to skip:


For example:

In request 1:

pm.variable.set("skip", true) // to skip request 2

in request 2:

pm.variable.set("skip", false ) // to ensure remaining requests don't skip collection script

And in collection add

if (!pm.variable.get("skip")) {
    //then execute
}
like image 180
PDHide Avatar answered Jul 26 '26 08:07

PDHide



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!