Disable collection pre-request script at request level

Viewed 1817

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.

I can't find a way to do this; does anybody know if this is possible, and how?

Thanks in advance!

1 Answers

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

if (pm.info.request !== "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:

eg:

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.set("skip")) {
    //then execute
}
Related