Setting up Conditional Workflow in Postman

Setting up Conditional Workflow in Postman

Audience : Postman user with collection working knowledge

A workflow is a sequence of things to achieve a particular task. In Postman, workflow is the flow of requests in a defined sequence. In research or quick POC, this workflow can be very handy.

Let's setup Postman workflow with our dummy use case.

Use Case : I live in NJ. When co levels > 160, I plan to visit Icelander else Norway. If any of these two countries have co level greater than 150 then it's Greenland.

I am using openweather API for fetching current co level using Air pollution API.

My PlanVisit collection looks like Screen Shot 2022-07-23 at 12.45.40 PM.png

Postman use setNextRequest for setting up the workflow. When we want to forward the call to next request use:

 postman.setNextRequest("<<RequestName Or RequestID>>")

and, to stop

 postman.setNextRequest(null)

Let's put our logic in a neat way

If co > 160, set postman.setNextRequest('iceland') 
Else, postman.setNextRequest('norway')
If at destination check co >150, set postman.setNextRequest('greenland')
Else, postman.setNextRequest(null)
If at greenland, set postman.setNextRequest(null)

In Postman, test case for request current_airQuality @ NJ looks like as below Screen Shot 2022-07-23 at 12.58.45 PM.png

Finally run the PlanVisit collection Screen Shot 2022-07-23 at 11.59.31 AM.png

See the results promptly Screen Shot 2022-07-23 at 11.59.51 AM.png

If you are interested in watching a screen capture Click here

Sharing my Postman public collection, fork it, play with it and share how did you use conditional workflows.

Hope this helps!