0
0
Postmantesting~10 mins

Send request block 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 set the HTTP method to POST in the request block.

Postman
pm.sendRequest({ method: '[1]', url: 'https://api.example.com/data' }, function (err, res) { console.log(res); });
Drag options to blanks, or click blank then click option'
APOST
BGET
CPUT
DDELETE
Attempts:
3 left
💡 Hint
Common Mistakes
Using GET instead of POST
Using PUT when only sending data
2fill in blank
medium

Complete the code to set the request URL correctly.

Postman
pm.sendRequest({ method: 'POST', url: '[1]' }, function (err, res) { console.log(res); });
Drag options to blanks, or click blank then click option'
Ahttps://api.example.com/data
Bapi.example.com/data
Chttp//api.example.com/data
Dhttps:/api.example.com/data
Attempts:
3 left
💡 Hint
Common Mistakes
Missing https://
Typo in protocol like http// or https:/
3fill in blank
hard

Fix the error in the headers object to set Content-Type to application/json.

Postman
pm.sendRequest({ method: 'POST', url: 'https://api.example.com/data', headers: { '[1]': 'application/json' } }, function (err, res) { console.log(res); });
Drag options to blanks, or click blank then click option'
Acontent-type
BContenttype
CcontentType
DContent-Type
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or camelCase header names
Misspelling the header key
4fill in blank
hard

Fill both blanks to send JSON data with a POST request.

Postman
pm.sendRequest({ method: 'POST', url: 'https://api.example.com/data', headers: { 'Content-Type': '[1]' }, body: { [2]: JSON.stringify({ name: 'John', age: 30 }) } }, function (err, res) { console.log(res); });
Drag options to blanks, or click blank then click option'
Aapplication/json
Braw
Cform-data
Dtext
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong Content-Type like text or form-data
Using incorrect body type
5fill in blank
hard

Fill all three blanks to handle the response status and log success or error.

Postman
pm.sendRequest({ method: 'POST', url: 'https://api.example.com/data', headers: { 'Content-Type': 'application/json' }, body: { raw: JSON.stringify({ name: 'John' }) } }, function (err, res) { if (res.statusCode [1] 200) { console.log('[2]'); } else { console.log('[3]'); } });
Drag options to blanks, or click blank then click option'
A===
BSuccess
CError
D!==
Attempts:
3 left
💡 Hint
Common Mistakes
Using assignment = instead of comparison ===
Logging wrong messages
Using !== instead of === for success check