0
0
Postmantesting~10 mins

Setting variables from response 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 set a variable from the JSON response in Postman.

Postman
pm.environment.set('userId', pm.response.json().[1]);
Drag options to blanks, or click blank then click option'
Aid
Bstatus
Ctoken
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong key name that does not exist in the response.
Forgetting to parse the response JSON before accessing properties.
2fill in blank
medium

Complete the code to set a global variable from a nested JSON response property.

Postman
pm.globals.set('authToken', pm.response.json().data.[1]);
Drag options to blanks, or click blank then click option'
Astatus
Btoken
Cid
Duser
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to access a property that is not nested under data.
Using environment variables instead of global variables when the task asks for global.
3fill in blank
hard

Fix the error in the code to correctly set a variable from an array in the response.

Postman
pm.environment.set('firstItem', pm.response.json().items[[1]]);
Drag options to blanks, or click blank then click option'
A-1
B1
Citems
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 1 as the index to get the first item.
Using a string instead of a number as the index.
4fill in blank
hard

Fill both blanks to set a variable from a nested array object property in the response.

Postman
pm.collectionVariables.set('email', pm.response.json().users[[1]].[2]);
Drag options to blanks, or click blank then click option'
A0
Bemail
C1
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using index 1 instead of 0 to get the first user.
Using the wrong property name like name instead of email.
5fill in blank
hard

Fill all three blanks to set a variable from a deeply nested JSON response property.

Postman
pm.environment.set('city', pm.response.json().[1][[2]].address.[3]);
Drag options to blanks, or click blank then click option'
Ausers
B2
Ccity
Dprofiles
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong array name like profiles.
Using index 3 instead of 2 for the third item.
Using the wrong property name instead of city.