Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to set the form-data key in Postman.
Postman
pm.request.body.formdata.add({ key: '[1]', value: 'test' }); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'password' or 'token' as the key when username is expected.
✗ Incorrect
The key 'username' is commonly used in form-data to identify the user field.
2fill in blank
mediumComplete the code to check if the form-data body contains a key.
Postman
const hasKey = pm.request.body.formdata.has('[1]');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using keys like 'session' or 'auth' which may not exist in form-data.
✗ Incorrect
Checking for 'username' key is common when validating form-data content.
3fill in blank
hardFix the error in the code to correctly set a form-data value.
Postman
pm.request.body.formdata.get('[1]').value = 'newValue';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using keys that do not exist in form-data causing runtime errors.
✗ Incorrect
Using 'username' ensures the correct form-data key is updated.
4fill in blank
hardFill both blanks to add a new form-data key and value.
Postman
pm.request.body.formdata.add({ key: '[1]', value: '[2]' }); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing keys and values incorrectly or using invalid tokens.
✗ Incorrect
The key 'apiKey' with value 'abcdef' is a common pair in form-data for authentication.
5fill in blank
hardFill all three blanks to update a form-data key's value and check its existence.
Postman
if (pm.request.body.formdata.has('[1]')) { pm.request.body.formdata.get('[2]').value = '[3]'; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different keys in has() and get() causing errors.
✗ Incorrect
This code checks if 'sessionId' exists, then updates its value to 'xyz789'.