Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is chaining request data in Postman?
Chaining request data means using data from one API response as input for the next API request. It helps test workflows where requests depend on each other.
Click to reveal answer
beginner
How do you extract data from a response in Postman to use in the next request?
You use pm.response.json() to get the response body, then save needed values with pm.environment.set('key', value) to reuse later.
Click to reveal answer
beginner
Why use environment variables in chaining requests?
Environment variables store data between requests. They keep values like tokens or IDs so you can reuse them in later requests easily.
Click to reveal answer
intermediate
Show a simple example of chaining request data in Postman tests.
In the first request test script: <br><pre>const jsonData = pm.response.json();
pm.environment.set('userId', jsonData.id);</pre><br>Then in the next request URL or body, use <code>{{userId}}</code> to insert that value.
Click to reveal answer
beginner
What happens if you don’t chain requests properly in a test sequence?
The next requests may fail because they miss required data like IDs or tokens. This breaks the test flow and gives errors.
Click to reveal answer
In Postman, which method extracts JSON data from a response?
Apm.response.text()
Bpm.request.body()
Cpm.environment.get()
Dpm.response.json()
✗ Incorrect
pm.response.json() parses the response body as JSON so you can access its data.
How do you save a value from a response to reuse in later requests?
Apm.environment.set('key', value)
Bpm.response.save('key', value)
Cpm.request.set('key', value)
Dpm.variables.get('key')
✗ Incorrect
pm.environment.set stores a value in environment variables for reuse.
What placeholder syntax is used to insert environment variables in Postman requests?
A[variableName]
B{{variableName}}
C<variableName>
D(variableName)
✗ Incorrect
Double curly braces {{variableName}} are used to insert variables.
Why is chaining request data important in API testing?
ATo test dependent workflows where one request needs data from another
BTo speed up tests by running requests in parallel
CTo avoid writing test scripts
DTo skip authentication steps
✗ Incorrect
Chaining ensures tests mimic real API flows where requests depend on previous data.
If a chained request fails due to missing data, what is the likely cause?
AThe request URL is too long
BThe API server is down
CThe previous request did not save the needed data
DThe Postman app is outdated
✗ Incorrect
Missing saved data from earlier requests breaks the chain and causes failure.
Explain how to chain request data in Postman using environment variables.
Think about how you pass info from one step to the next in a recipe.
You got /3 concepts.
Describe why chaining request data is useful in API testing.
Imagine ordering food where each step depends on the last.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of chaining request data in Postman?
easy
A. To pass data from one API request to another for connected testing
B. To run multiple requests at the same time
C. To change the request method automatically
D. To generate random data for each request
Solution
Step 1: Understand chaining request data
Chaining request data means using data from one API response in the next request to keep tests connected.
Step 2: Identify the purpose
This helps simulate real user flows where one action depends on the previous one.
Final Answer:
To pass data from one API request to another for connected testing -> Option A
Quick Check:
Chaining = passing data between requests [OK]
Hint: Chaining means passing data forward between requests [OK]
Common Mistakes:
Thinking chaining runs requests simultaneously
Confusing chaining with changing HTTP methods
Assuming chaining generates random data
2. Which Postman script correctly saves a value from a JSON response to an environment variable named userId?
easy
A. pm.response.set('userId', pm.environment.json().id);
B. pm.environment.get('userId', pm.response.json().id);
C. pm.response.get('userId', pm.environment.json().id);
D. pm.environment.set('userId', pm.response.json().id);
Solution
Step 1: Identify correct method to save variable
Use pm.environment.set(key, value) to save data to environment variables.
Step 2: Extract value from response JSON
Use pm.response.json() to parse JSON and get the id field.
Final Answer:
pm.environment.set('userId', pm.response.json().id); -> Option D
Quick Check:
Set environment variable = pm.environment.set [OK]
Hint: Use pm.environment.set to save data from pm.response.json() [OK]
Common Mistakes:
Using pm.environment.get to set a variable
Confusing pm.response and pm.environment methods
Trying to get data from environment instead of response
3. Given this Postman test script after a request:
const data = pm.response.json();
pm.environment.set('userId', data.user.id);
But the environment variable userId is always empty after the request. What is the likely problem?
medium
A. The script must run before the request
B. The response JSON does not have a user object
C. You must use pm.variables.set instead
D. pm.environment.set cannot save variables
Solution
Step 1: Check JSON structure
If data.user is undefined, accessing data.user.id returns undefined, so variable is empty.
Step 2: Confirm environment.set works correctly
pm.environment.set works if given a valid value, so problem is likely missing user in response.
Final Answer:
The response JSON does not have a user object -> Option B
Quick Check:
Missing JSON key = empty variable [OK]
Hint: Verify JSON keys exist before accessing nested values [OK]
Common Mistakes:
Assuming pm.environment.set is broken
Using wrong method like pm.variables.set
Running script before response is received
5. You want to chain two requests where the first returns a list of users:
{"users": [{"id": 1}, {"id": 2}]}
You want to save the id of the first user to an environment variable firstUserId and use it in the second request URL as /users/{{firstUserId}}. Which script correctly does this in the first request's Tests tab?
hard
A. const jsonData = pm.response.json();
pm.environment.set('firstUserId', jsonData.users[0].id);
B. const jsonData = pm.response.json();
pm.environment.set('firstUserId', jsonData.users.id[0]);
C. const jsonData = pm.response.json();
pm.environment.set('firstUserId', jsonData.users[1].id);
D. const jsonData = pm.response.json();
pm.environment.set('firstUserId', jsonData.user[0].id);
Solution
Step 1: Parse response JSON correctly
The response has a users array with objects containing id. The first user is at index 0.
Step 2: Save first user's id properly
Access jsonData.users[0].id and save it with pm.environment.set.
Final Answer:
const jsonData = pm.response.json();
pm.environment.set('firstUserId', jsonData.users[0].id); -> Option A
Quick Check:
Array index 0 for first user id [OK]
Hint: Use array index [0] to get first item in JSON array [OK]
Common Mistakes:
Using wrong array index or property name
Accessing id as users.id[0] instead of users[0].id