Workflow sequencing helps you run tests in a specific order. This makes sure each step happens only after the previous one finishes successfully.
Workflow sequencing in Postman
Start learning this pattern below
Jump into concepts and practice - no test required
or
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Introduction
Syntax
Postman
pm.sendRequest(request, function (err, res) {
// handle response here
});Use pm.sendRequest inside a test or pre-request script to call another request.
Use environment or collection variables to pass data between requests.
Examples
Postman
pm.sendRequest({
url: 'https://api.example.com/login',
method: 'POST',
header: { 'Content-Type': 'application/json' },
body: { mode: 'raw', raw: JSON.stringify({ username: 'test', password: 'test' }) }
}, function (err, res) {
pm.environment.set('token', res.json().token);
});Postman
pm.sendRequest({
url: 'https://api.example.com/user',
method: 'POST',
header: { 'Content-Type': 'application/json' },
body: { mode: 'raw', raw: JSON.stringify({ name: 'John' }) }
}, function (err, res) {
pm.environment.set('userId', res.json().id);
});Sample Program
This example shows two steps: first creating a user, then getting that user's details. The second step waits for the first to finish and uses the user ID from it.
Postman
// Step 1: Create user pm.sendRequest({ url: 'https://api.example.com/users', method: 'POST', header: { 'Content-Type': 'application/json' }, body: { mode: 'raw', raw: JSON.stringify({ name: 'Alice' }) } }, function (err, res) { if (err) { console.log('User creation failed'); return; } const userId = res.json().id; pm.environment.set('userId', userId); console.log('User created with ID:', userId); // Step 2: Get user details pm.sendRequest({ url: `https://api.example.com/users/${userId}`, method: 'GET' }, function (err2, res2) { if (err2) { console.log('Failed to get user details'); return; } console.log('User details:', res2.json()); }); });
Important Notes
Always check for errors in callbacks to avoid silent failures.
Use environment or collection variables to share data between requests.
Workflow sequencing helps test real user flows step-by-step.
Summary
Workflow sequencing runs requests in order, passing data between them.
Use pm.sendRequest to call requests inside scripts.
This helps test multi-step processes reliably.
Practice
1. What is the main purpose of workflow sequencing in Postman?
easy
Solution
Step 1: Understand workflow sequencing
Workflow sequencing means running requests one after another in a set order.Step 2: Identify the purpose in Postman
It allows passing data from one request to the next, making multi-step testing reliable.Final Answer:
To run multiple requests in a specific order and share data between them -> Option DQuick Check:
Workflow sequencing = ordered requests with data sharing [OK]
Hint: Think: run requests step-by-step sharing info [OK]
Common Mistakes:
- Confusing workflow sequencing with documentation generation
- Thinking it creates charts or encrypts requests
- Believing requests run randomly without order
2. Which Postman script command is used to call another request inside a test script for workflow sequencing?
easy
Solution
Step 1: Recall Postman scripting commands
Postman provides a method to send HTTP requests programmatically inside scripts.Step 2: Identify the correct method for calling requests
The correct method ispm.sendRequest(), which sends a request and handles its response.Final Answer:
pm.sendRequest() -> Option BQuick Check:
Call requests inside scripts = pm.sendRequest() [OK]
Hint: Remember: sendRequest sends HTTP calls inside scripts [OK]
Common Mistakes:
- Using non-existent methods like pm.callRequest()
- Confusing with pm.executeRequest() or pm.runRequest() which don't exist
- Misspelling the method name
3. Consider this Postman test script snippet inside Request A:
What will be the value of
pm.sendRequest('https://api.example.com/token', (err, res) => {
pm.environment.set('token', res.json().access_token);
});What will be the value of
token in environment after this runs?medium
Solution
Step 1: Understand pm.sendRequest callback
The callback receives the response objectres, which can be parsed as JSON.Step 2: Extract and set environment variable
The script setstokentores.json().access_token, which is the access token string from the response.Final Answer:
The access_token value from the JSON response of the called request -> Option AQuick Check:
pm.sendRequest sets env var = access_token value [OK]
Hint: pm.sendRequest callback can set env vars from response JSON [OK]
Common Mistakes:
- Assuming pm.sendRequest cannot set variables
- Thinking the whole JSON is stored instead of just access_token
- Confusing asynchronous callback behavior
4. You wrote this Postman test script to run Request B after Request A:
Why might the second request fail or use an empty
pm.sendRequest('https://api.example.com/data', (err, res) => {
pm.environment.set('dataId', res.json().id);
});
pm.sendRequest('https://api.example.com/details/{{dataId}}', (err, res) => {
console.log(res.json());
});Why might the second request fail or use an empty
dataId?medium
Solution
Step 1: Analyze asynchronous behavior of pm.sendRequest
pm.sendRequest runs asynchronously, so the second call may start before the first finishes.Step 2: Understand timing of environment variable setting
The variabledataIdis set only after the first request completes, so the second request may see it as empty if it runs too soon.Final Answer:
Because pm.sendRequest is asynchronous, the second request runs before dataId is set -> Option CQuick Check:
Async calls need chaining to ensure order [OK]
Hint: Async calls run out of order unless chained properly [OK]
Common Mistakes:
- Thinking environment variables can't be used in URLs
- Believing pm.sendRequest can't be called multiple times
- Assuming console.log is disallowed in callbacks
5. You want to test a multi-step user signup flow in Postman using workflow sequencing. The steps are:
1. Create user (returns userId)
2. Verify email (needs userId)
3. Set user preferences (needs userId)
Which approach correctly sequences these requests and shares
1. Create user (returns userId)
2. Verify email (needs userId)
3. Set user preferences (needs userId)
Which approach correctly sequences these requests and shares
userId between them?hard
Solution
Step 1: Understand multi-step flow needs ordered execution
Each step depends on the previous step's userId, so requests must run one after another.Step 2: Use pm.sendRequest with environment variables to pass data
Calling the next request inside the previous request's test script and setting userId as an environment variable ensures correct sequencing and data sharing.Final Answer:
Use pm.sendRequest inside the test script of each step to call the next, setting environment variables for userId -> Option AQuick Check:
Chain requests with pm.sendRequest and env vars for data flow [OK]
Hint: Chain requests with pm.sendRequest and env vars [OK]
Common Mistakes:
- Running requests manually without automation
- Not sharing variables between requests
- Calling requests simultaneously causing race conditions
