Exit a request based on a value in a global variable

we have 2 requests, the first request does a GET and we loop through the results looking for a particular value. If we find the value, we set a global variable called “brandAmbassadorBadgeId”
In our 2nd request, we would like to check if the global variable “brandAmbassadorBadgeId” has a value, if it contains a value (i.e. length > 0) then we would like to exit, the 2nd request and NOT execute the POST. we would only execute the POST if the length of the variable is equal to 0.
Is this possible?


You should do the branching logic in the tests of your first request.

In the tests tab, let’s say the code looks like this:

const jsonData = pm.response.json();

const brandAmbassadorBadgeId = jsonData.brandAmbassadorBadgeId;

By setting postman.setNextRequest(null) in your tests, you tell the collection runner to end the execution. By not setting it (which would happen if that variable had a value) the collection runner will continue with the next request.