0
0
Postmantesting~20 mins

Using extracted data in next request in Postman - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Postman Data Chaining Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the value of the variable after extraction?
You run this Postman test script after a response:
pm.test("Extract userId", () => {
  const jsonData = pm.response.json();
  pm.environment.set("userId", jsonData.user.id);
});

Given the response body:
{"user": {"id": 42, "name": "Alice"}}

What will be the value of the environment variable userId?
A42 (number)
B"42" (string)
Cundefined
Dnull
Attempts:
2 left
💡 Hint
Remember that environment variables in Postman are stored as strings.
assertion
intermediate
2:00remaining
Which assertion correctly uses extracted data in the next request?
You extracted a token in the first request and saved it as an environment variable authToken. Which assertion in the next request correctly checks the token is used in the header?
Apm.expect(pm.request.headers.get('Authorization')).to.eql('Bearer ' + pm.environment.get('authToken'));
Bpm.expect(pm.request.headers.get('Authorization')).to.eql(`Bearer ${authToken}`);
Cpm.expect(pm.request.headers.get('Authorization')).to.eql('Bearer {{authToken}}');
Dpm.expect(pm.request.headers.get('Authorization')).to.eql('Bearer authToken');
Attempts:
2 left
💡 Hint
Use pm.environment.get to access environment variables in scripts.
🔧 Debug
advanced
2:00remaining
Why does the next request fail to use extracted data?
You extracted a sessionId in the first request with:
pm.environment.set('sessionId', pm.response.json().session.id);

In the next request, you use the header:
Authorization: Bearer {{sessionId}}

But the request fails with unauthorized error. What is the most likely reason?
AThe variable sessionId is saved but the next request uses a different environment without that variable.
BThe variable sessionId is not available because environment variables require manual saving.
CThe variable sessionId was not saved because pm.environment.set was called inside pm.test block.
DThe variable sessionId is overwritten by a global variable with empty value.
Attempts:
2 left
💡 Hint
Check if the environment selected for the next request is the same as where the variable was saved.
🧠 Conceptual
advanced
2:00remaining
What is the best way to pass extracted data between requests in Postman?
You want to extract a userId from one request and use it in multiple subsequent requests. Which method ensures the data is available across all requests in the collection?
ASave the userId as a global variable using pm.globals.set.
BSave the userId as a local variable in the first request's Tests tab.
CSave the userId as an environment variable using pm.environment.set.
DSave the userId in the request body of the next request manually.
Attempts:
2 left
💡 Hint
Local variables only exist during one request execution.
framework
expert
3:00remaining
How to chain requests using extracted data with Postman Collection Runner?
You have a collection with two requests: Login and GetProfile. Login extracts a token and saves it as environment variable token. GetProfile uses this token in the Authorization header.

Which setup ensures the Collection Runner correctly passes the token from Login to GetProfile?
ARun the collection with no environment selected; token is saved globally.
BRun the collection with an environment selected; Login saves token with pm.globals.set; GetProfile uses {{token}} in header.
CRun the collection with an environment selected; Login saves token with pm.variables.set; GetProfile uses {{token}} in header.
DRun the collection with an environment selected; Login saves token with pm.environment.set; GetProfile uses {{token}} in header.
Attempts:
2 left
💡 Hint
Collection Runner uses the selected environment to share variables between requests.