Recall & Review
beginner
What is the purpose of setting variables from a response in Postman?
It allows you to save data from an API response to use later in your tests or requests, making your tests dynamic and reusable.
Click to reveal answer
beginner
How do you access a JSON field named 'token' from a response in Postman test script?
Use
pm.response.json().token to get the value of the 'token' field from the JSON response.Click to reveal answer
beginner
Which Postman method is used to set an environment variable from a response?
Use
pm.environment.set('variableName', value) to save a variable in the environment scope.Click to reveal answer
intermediate
Write a simple Postman test script snippet to save the 'id' field from a JSON response as a collection variable named 'userId'.
const jsonData = pm.response.json();
pm.collectionVariables.set('userId', jsonData.id);Click to reveal answer
beginner
Why is it better to use variables in Postman tests instead of hardcoding values?
Variables make tests flexible and maintainable by allowing reuse of dynamic data, reducing errors and manual updates.
Click to reveal answer
Which method extracts JSON data from a Postman response?
✗ Incorrect
pm.response.json() parses the response body as JSON so you can access its fields.
How do you set a global variable named 'sessionId' in Postman from a response value 'sid'?
✗ Incorrect
pm.globals.set() sets a global variable accessible across all collections and environments.
What is the correct way to save a response header 'Auth-Token' as an environment variable 'authToken'?
✗ Incorrect
pm.response.headers.get() retrieves the header value; pm.environment.set() saves it as a variable.
Which scope is NOT available for variables in Postman?
✗ Incorrect
Postman does not have a 'Session' variable scope; it has Global, Environment, Collection, and Local.
Why should you check if a response field exists before setting a variable from it?
✗ Incorrect
Checking prevents runtime errors when the expected field is not present in the response.
Explain how to extract a value from a JSON response and save it as an environment variable in Postman.
Think about parsing JSON and setting variables in Postman scripts.
You got /3 concepts.
Describe why setting variables from responses is useful in API testing with Postman.
Consider how tests behave when data changes.
You got /3 concepts.