0
0
Postmantesting~10 mins

Why pre-request scripts prepare data in Postman - Test Your Understanding

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

Complete the code to set a variable in a pre-request script.

Postman
pm.variables.set('[1]', '12345');
Drag options to blanks, or click blank then click option'
Atoken
Bresponse
Crequest
DuserId
Attempts:
3 left
💡 Hint
Common Mistakes
Using response or request objects directly in variable names.
2fill in blank
medium

Complete the code to get an environment variable in a pre-request script.

Postman
const token = pm.environment.get('[1]');
Drag options to blanks, or click blank then click option'
AuserId
BauthToken
CresponseTime
DrequestBody
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated variable names like responseTime or requestBody.
3fill in blank
hard

Fix the error in the pre-request script to correctly set a header.

Postman
pm.request.headers.add({ key: 'Authorization', value: '[1]' });
Drag options to blanks, or click blank then click option'
Apm.environment.get('authToken')
BauthToken
Cpm.variables.get('authToken')
Dtoken
Attempts:
3 left
💡 Hint
Common Mistakes
Using just the variable name without getting its value.
4fill in blank
hard

Fill both blanks to prepare a timestamp and set it as a variable.

Postman
const timestamp = new Date().[1]();
pm.variables.set('requestTime', [2]);
Drag options to blanks, or click blank then click option'
AgetTime
BtoISOString
Ctimestamp
DDate.now()
Attempts:
3 left
💡 Hint
Common Mistakes
Using toISOString() returns a string, not a timestamp number.
5fill in blank
hard

Fill all three blanks to create a random user ID and set it as an environment variable.

Postman
const randomId = Math.[1]() * 1000;
pm.environment.set('[2]', randomId.toString());
pm.variables.set('[3]', randomId);
Drag options to blanks, or click blank then click option'
Arandom
BuserId
CrandomUserId
Duser_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect method names or inconsistent variable names.