Challenge - 5 Problems
Response Extraction Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Extracting a single value from JSON response
Given the following Postman test script, what will be the value of
userId after execution if the response body is {"user":{"id":42,"name":"Alice"}}?Postman
const responseJson = pm.response.json(); const userId = responseJson.user.id;
Attempts:
2 left
💡 Hint
Remember that JSON numbers are parsed as numbers, not strings.
✗ Incorrect
The response JSON has a user object with an id property of number 42. Accessing responseJson.user.id returns the number 42.
❓ assertion
intermediate2:00remaining
Correct assertion to check extracted value
Which Postman test assertion correctly verifies that the extracted
token from the JSON response {"auth":{"token":"abc123"}} is exactly "abc123"?Postman
const responseJson = pm.response.json(); const token = responseJson.auth.token;
Attempts:
2 left
💡 Hint
Check the exact value and type of the token string.
✗ Incorrect
Option C correctly asserts that token equals the string 'abc123'. Other options check unrelated conditions.
🔧 Debug
advanced2:30remaining
Debugging extraction from nested JSON array
You want to extract the
id of the first item in the items array from this response: {"data":{"items":[{"id":10},{"id":20}]}}. The code below returns undefined. What is the problem?Postman
const responseJson = pm.response.json();
const firstItemId = responseJson.items[0].id;Attempts:
2 left
💡 Hint
Check the full path to the items array in the JSON structure.
✗ Incorrect
The items array is inside the data property, so the correct path is responseJson.data.items[0].id.
🧠 Conceptual
advanced2:00remaining
Understanding Postman environment variable extraction
Which statement correctly describes how to extract a value from a JSON response and save it as an environment variable in Postman?
Attempts:
2 left
💡 Hint
Remember the method to set environment variables in Postman scripts.
✗ Incorrect
pm.environment.set('varName', value) saves a variable in the environment scope for later use.
❓ framework
expert3:00remaining
Choosing the correct Postman test script for conditional extraction
You want to extract the
sessionId from the response only if the status code is 200. Which Postman test script correctly implements this conditional extraction?Attempts:
2 left
💡 Hint
Check the exact property name for status code in Postman response object.
✗ Incorrect
pm.response.code is the correct property for the numeric status code. pm.response.status is a string like 'OK'.