6

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?

double-beep
  • 5,031
  • 17
  • 33
  • 41
89f3a1c
  • 1,430
  • 1
  • 14
  • 24

1 Answers1

10

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
}
double-beep
  • 5,031
  • 17
  • 33
  • 41
PDHide
  • 18,113
  • 2
  • 31
  • 46