0
0
Postmantesting~10 mins

Extracting data from responses 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 value of 'token' from the JSON response.

Postman
let token = pm.response.json().[1];
Drag options to blanks, or click blank then click option'
Atoken
Bstatus
Cheaders
Dbody
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to access 'token' directly from pm.response without parsing JSON.
Using incorrect property names like 'status' or 'headers'.
2fill in blank
medium

Complete the code to check if the response status code is 200.

Postman
pm.test('Status code is 200', function () { pm.response.to.have.status([1]); });
Drag options to blanks, or click blank then click option'
A404
B201
C200
D500
Attempts:
3 left
💡 Hint
Common Mistakes
Using 404 which means 'Not Found'.
Using 201 which means 'Created' but not the expected here.
3fill in blank
hard

Fix the error in the code to correctly extract the 'userId' from the JSON response.

Postman
let userId = pm.response.json()[1];
Drag options to blanks, or click blank then click option'
A['userId']
B.userId
C.userId()
DuserId
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses like a function call.
Trying to access property without dot or brackets.
4fill in blank
hard

Fill both blanks to extract the 'email' from the first user in the 'users' array in the response.

Postman
let email = pm.response.json().[1][[2]].email;
Drag options to blanks, or click blank then click option'
Ausers
B0
C1
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'data' instead of 'users' as the array name.
Using index 1 which is the second user.
5fill in blank
hard

Fill all three blanks to create a test that checks if the response JSON has a 'success' property set to true.

Postman
pm.test('Response has success true', function () { pm.expect(pm.response.json().[1]).to.eql([2]); pm.expect(typeof pm.response.json().[3]).to.equal('boolean'); });
Drag options to blanks, or click blank then click option'
Asuccess
Btrue
Dstatus
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'status' instead of 'success' property.
Using string 'true' instead of boolean true.