0
0
Postmantesting~10 mins

Variable syntax ({{variable}}) 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 correctly reference a variable in Postman.

Postman
pm.environment.set([1], '12345');
Drag options to blanks, or click blank then click option'
A'userId'
BuserId.value
C{{userId}}
DuserId
Attempts:
3 left
💡 Hint
Common Mistakes
Using {{userId}} directly without quotes causes syntax errors.
Using variable.value is incorrect for setting variables.
2fill in blank
medium

Complete the code to retrieve a variable value using Postman variable syntax.

Postman
const token = pm.variables.get('[1]');
Drag options to blanks, or click blank then click option'
Atoken
Bpm.variables
CauthToken
D{{authToken}}
Attempts:
3 left
💡 Hint
Common Mistakes
Including curly braces inside the string causes the variable not to be found.
Passing the variable object instead of its name.
3fill in blank
hard

Fix the error in the code to correctly use a variable in a request URL.

Postman
const url = `https://api.example.com/users/$[1]/details`;
Drag options to blanks, or click blank then click option'
Apm.variables.get('userId')
BuserId
C{{userId}}
D'userId'
Attempts:
3 left
💡 Hint
Common Mistakes
Using {{userId}} inside backticks does not get replaced automatically.
Using the variable name as a string does not insert the value.
4fill in blank
hard

Fill both blanks to correctly set and then use a variable in Postman scripts.

Postman
pm.environment.set('[1]', '12345');
const id = pm.environment.get('[2]');
Drag options to blanks, or click blank then click option'
AsessionId
BuserId
DauthToken
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names causes undefined values.
Omitting quotes around variable names causes errors.
5fill in blank
hard

Fill all three blanks to create a dynamic request URL using Postman variables.

Postman
const baseUrl = pm.environment.get('[1]');
const user = pm.variables.get('[2]');
const fullUrl = `$[3]/users/${user}/profile`;
Drag options to blanks, or click blank then click option'
Abase_url
Busername
CbaseUrl
DuserId
Attempts:
3 left
💡 Hint
Common Mistakes
Using Postman variable syntax inside template literals instead of JavaScript variables.
Mismatching variable names between get() calls.