0
0
Postmantesting~10 mins

Chaining request data 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 first response.

Postman
var token = pm.response.json().[1];
Drag options to blanks, or click blank then click option'
Aaccess_token
Bheaders
Cstatus
Durl
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to access token from headers instead of JSON body.
Using incorrect key names like 'status' or 'url'.
2fill in blank
medium

Complete the code to set the extracted token as an environment variable.

Postman
pm.environment.set('authToken', [1]);
Drag options to blanks, or click blank then click option'
Apm.response.headers.get('Authorization')
Btoken
Cpm.response.json().token
Dpm.request.body
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to set the environment variable directly from response without storing it first.
Using incorrect methods like accessing headers or request body.
3fill in blank
hard

Fix the error in the code to use the environment variable in the next request header.

Postman
pm.request.headers.add({ key: 'Authorization', value: 'Bearer ' + [1] });
Drag options to blanks, or click blank then click option'
Apm.environment.get('authToken')
B{{authToken}}
Ctoken
DauthToken
Attempts:
3 left
💡 Hint
Common Mistakes
Using {{authToken}} inside script strings, which doesn't get resolved.
Using plain variable names like 'authToken' without retrieval method.
4fill in blank
hard

Fill both blanks to correctly extract user ID and set it as a global variable.

Postman
var userId = pm.response.json().[1];
pm.globals.set('[2]', userId);
Drag options to blanks, or click blank then click option'
Auser.id
Bid
CuserId
DuserID
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect key names like 'user.id' which is not valid syntax here.
Mismatching variable names between extraction and setting.
5fill in blank
hard

Fill all three blanks to create a test that checks if the response status is 200 and the token exists.

Postman
pm.test('Status code is 200', function () {
    pm.response.to.have.status([1]);
});
pm.test('Token is present', function () {
    pm.expect(pm.response.json().[2]).to.exist;
    pm.environment.set('token', pm.response.json().[3]);
});
Drag options to blanks, or click blank then click option'
Aaccess_token
B200
Dtoken
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong status codes like 201 or 400.
Mismatching token key names in the test and environment set.