0
0
Postmantesting~10 mins

Using extracted data in next request in Postman - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to extract the token from the response and save it as an environment variable.

Postman
pm.environment.set('authToken', pm.response.json().[1]);
Drag options to blanks, or click blank then click option'
Aerror
Bstatus
Ctoken
Dmessage
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect key names like 'status' or 'message' instead of 'token'.
Not using pm.response.json() to parse the response.
2fill in blank
medium

Complete the code to use the extracted token in the Authorization header of the next request.

Postman
pm.request.headers.add({ key: 'Authorization', value: 'Bearer ' + pm.environment.get('[1]') });
Drag options to blanks, or click blank then click option'
AtokenValue
BaccessToken
CsessionToken
DauthToken
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name that was not set previously.
Forgetting to add 'Bearer ' before the token.
3fill in blank
hard

Fix the error in the test script to correctly extract the user ID from the response and save it.

Postman
let userId = pm.response.json().[1];
pm.environment.set('userId', userId);
Drag options to blanks, or click blank then click option'
Auserid
Bid
Cuser_id
DuserId
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'user_id' or 'userid' which may not exist in the response.
Using wrong case like 'userId' if the response uses 'id'.
4fill in blank
hard

Fill both blanks to create a test that checks if the extracted token is not empty and saves it.

Postman
let token = pm.response.json().[1];
if (token [2] '') {
    pm.environment.set('authToken', token);
}
Drag options to blanks, or click blank then click option'
Atoken
B!==
C==
DaccessToken
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '!==' causing wrong condition.
Using wrong key name like 'accessToken' if the response uses 'token'.
5fill in blank
hard

Fill all three blanks to extract 'id' and 'name' from the response and save them as environment variables if 'id' is greater than 0.

Postman
let data = pm.response.json();
let userId = data.[1];
let userName = data.[2];
if (userId [3] 0) {
    pm.environment.set('userId', userId);
    pm.environment.set('userName', userName);
}
Drag options to blanks, or click blank then click option'
Aid
Bname
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong keys like 'userId' or 'userName' if response uses 'id' and 'name'.
Using '<' instead of '>' causing wrong condition.