Can I check a request has been ran before running another?

Hi,

I want a request to check that a previous one has been ran before it runs.
I would assume that this would be done in a Pre-req. script but I don’t know how it would be done.

For context:
Request names:
> prereq
> project
> executionid
> testid

I want the requests “project”, “executionid” and “testid” to check that the prereq request has been executed.

The prereq stores variables in the environment that the three tests below use so I was thinking that I could check that those variables are present before running them but I wanted to know if there is a better way to do this.

I am using the Postman for Windows v7.29.1

Many thanks.

Is your goal here to prevent the last three requests from executing at all if “prereq” didn’t run successfully?

If you have them as separate requests in your collection, you are guaranteeing order.

Hi,
Yes - that’s what I’m expecting but I have other requests both before and after these that need to be run as well. Meaning that if prereq fails I don’t want everything after to fail also.

They are all in the same collection and in that specific order

Ok great, if that’s the case then you can keep everything as separate requests and just use postman.setNextRequest to build your conditional workflow.

Postman Documentation

Thanks for this, helps a lot!

1 Like