0
0
Postmantesting~20 mins

Saving responses in Postman - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Response Saver Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this Postman test script?
Consider this Postman test script that saves a response value to an environment variable. What will be the value of the environment variable userId after running this test if the response body is {"id": 42, "name": "Alice"}?
Postman
pm.test("Save userId", function () {
    var jsonData = pm.response.json();
    pm.environment.set("userId", jsonData.id);
});
A42 (number)
Bundefined
C"42" (string)
Dnull
Attempts:
2 left
💡 Hint
Remember that Postman environment variables store values as strings.
assertion
intermediate
2:00remaining
Which assertion correctly verifies a saved response value in Postman?
You saved the response field token to an environment variable authToken. Which assertion correctly checks that authToken is not empty in a test script?
Apm.expect(pm.environment.get('authToken')).to.not.be.empty;
Bpm.expect(pm.environment.authToken).to.exist;
Cpm.expect(pm.environment.get('authToken')).to.equal(null);
Dpm.expect(pm.environment.get('authToken')).to.be.undefined;
Attempts:
2 left
💡 Hint
Use the correct method to get environment variables and check for non-empty string.
🔧 Debug
advanced
2:00remaining
Why does this Postman script fail to save the response value?
This script tries to save response.data.id to an environment variable but it does not work. What is the likely cause?
Postman
pm.test("Save ID", function () {
    var id = pm.response.data.id;
    pm.environment.set("userId", id);
});
Apm.environment.set requires a callback function.
Bpm.response.data is undefined; should use pm.response.json() to parse JSON body.
Cpm.response.data.id is a reserved keyword and cannot be accessed.
Dpm.environment.set only accepts string literals, not variables.
Attempts:
2 left
💡 Hint
Check how to access JSON response body in Postman scripts.
framework
advanced
2:00remaining
Which Postman feature allows saving response data automatically for later use in a collection run?
You want to save parts of the response from one request and use them in subsequent requests automatically during a collection run. Which Postman feature supports this best?
AUsing the Postman Runner's built-in response caching
BUsing Postman monitors to save responses externally
CUsing the Postman console to copy response data manually
DUsing environment or collection variables set in test scripts
Attempts:
2 left
💡 Hint
Think about how variables can be shared across requests in a collection.
🧠 Conceptual
expert
2:00remaining
What is a key limitation when saving large response bodies as Postman environment variables?
When saving large JSON response bodies as environment variables in Postman, what is a common limitation you must consider?
AEnvironment variables have size limits and large data may be truncated or cause errors
BEnvironment variables automatically compress large data to save space
CEnvironment variables can only store numeric values, not JSON strings
DPostman converts large JSON to XML when saving as environment variables
Attempts:
2 left
💡 Hint
Think about storage limits in Postman environment variables.