0
0
Postmantesting~10 mins

Generating dynamic 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 generate a random integer between 1 and 100 in Postman.

Postman
var randomNumber = [1];
Drag options to blanks, or click blank then click option'
AMath.random()
Bpm.variables.set('randomNumber')
Cpm.environment.get('random')
DMath.floor(Math.random() * 100) + 1
Attempts:
3 left
💡 Hint
Common Mistakes
Using Math.random() alone returns a decimal between 0 and 1, not an integer.
Forgetting to add 1 shifts the range to 0-99 instead of 1-100.
2fill in blank
medium

Complete the code to set a dynamic timestamp variable in Postman.

Postman
pm.environment.set('timestamp', [1]);
Drag options to blanks, or click blank then click option'
ADate.now()
Bnew Date()
Cpm.variables.get('time')
Dmoment()
Attempts:
3 left
💡 Hint
Common Mistakes
Using new Date() directly stores a Date object, not a timestamp number.
Trying to get a variable that does not exist like 'time'.
3fill in blank
hard

Fix the error in the code to generate a random email address with a dynamic number in Postman.

Postman
var email = `user[1]@example.com`;
Drag options to blanks, or click blank then click option'
AMath.random()
BMath.floor(Math.random() * 1000)
Cpm.variables.get('random')
DDate.now()
Attempts:
3 left
💡 Hint
Common Mistakes
Using Math.random() directly inserts a decimal number.
Using variables that are not defined in the script.
4fill in blank
hard

Fill both blanks to create a dynamic JSON body with a random user ID and current timestamp in Postman.

Postman
{
  "userId": [1],
  "createdAt": [2]
}
Drag options to blanks, or click blank then click option'
AMath.floor(Math.random() * 10000)
Bnew Date()
CDate.now()
Dpm.variables.get('userId')
Attempts:
3 left
💡 Hint
Common Mistakes
Using new Date() for timestamp inserts a Date object, not a number.
Using undefined variables for userId.
5fill in blank
hard

Fill all three blanks to generate a dynamic Postman test that checks if the response time is less than 500ms and sets a variable with the current date string.

Postman
pm.test('Response time is fast', function () {
  pm.expect(pm.response.responseTime).to.be.[1](500);
});
pm.environment.set('currentDate', [2]);

var dateString = [3].toISOString();
Drag options to blanks, or click blank then click option'
Abelow
Bnew Date()
Dabove
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'above' instead of 'below' for the assertion.
Not creating a new Date object before calling toISOString.