- Postman - Discussion
- Postman - Useful Resources
- Postman - Quick Guide
- Postman - OAuth 2.0 Authorization
- Postman - Run Collections using Newman
- Postman - Newman Overview
- Postman - Sessions
- Postman - Cookies
- Postman - Mock Server
- Postman - Assertion
- Postman - Collection Runner
- Postman - Parameterize Requests
- Postman - Create Collections
- Postman - Create Tests for CRUD
- Postman - DELETE Requests
- Postman - PUT Requests
- Postman - POST Requests
- Postman - GET Requests
- Postman - Workflows
- Postman - Authorization
- Postman - Environment Variables
- Postman - Environment Setup
- Postman - Introduction
- Postman - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Postman - Workflows
In a Postman Collection, the requests are executed in the order in which they appear. Every request is run first by the order of the folder followed by any request at the Collection root.
Let us create a Collection (Collection1) with four requests. The details on how to create a Collection is discussed in detail in the Chapter about Create Collections.
Step 1 − Cpck on the arrow appearing to the right of the Collection name in the sidebar. Then, cpck on Run button to trigger execution of requests within the Collection.
Step 2 − The Collection Runner pop-up comes up. The RUN ORDER section shows the order in which the requests shall get executed from top to the bottom. (GET-<POST-<DEL-<PUT). Cpck on the Run Collection1 button.
Step 3 − Execution Results show the GET request executed first, followed by POST, then DEL and finally PUT, as mentioned in the RUN ORDER section in the Step 2.
If we want to change the order of the request to be executed (for example, first the Get Request shall run, followed by Create User, then Update Request and finally the Delete Request). We have to take the help of the function postman.setNextRequest().
This function has the feature to state which request shall execute next. The request name to be executed next is passed as a parameter to this function. As per the workflow, we have to add this function either in the Tests or Pre-request Script tab under the endpoint address bar in Postman.
The syntax for execution of a request in Postman is as follows −
postman.setNextRequest("name of request")
Implementation of a Workflow
The implementation of a workflow in Postman is explained below in a step wise manner −
Step 1 − Add the below script under the Tests tab, for the request – Create User.
postman.setNextRequest("Update Request")
The following screen will appear −
Step 2 − Add the below script under the Tests tab, for the request – Update Request.
postman.setNextRequest("Delete Request")
The following screen will appear −
Output of Workflow
Given below is the output of the workflow −
The output shows that Update Request and Delete Request are running in an infinite loop until we stop it by cpcking the Stop Run button.
Infinite Workflow Loop
If we want to stop the infinite Workflow loop via script, we have to add the below script for the request – Delete Request.
postman.setNextRequest(null)
The following screen will appear −
Again run the same Collection and output shall be as follows −
The output shows the order of execution as Get Request, Create User, Update Request and finally Delete Request.
Advertisements