0
0
Postmantesting~10 mins

REST API fundamentals review 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 specify the HTTP method for retrieving data from a REST API.

Postman
pm.sendRequest({ url: 'https://api.example.com/data', method: '[1]' }, function (err, res) { pm.test('Status code is 200', function () { pm.expect(res.code).to.equal(200); }); });
Drag options to blanks, or click blank then click option'
AGET
BPOST
CDELETE
DPUT
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST instead of GET for retrieving data.
2fill in blank
medium

Complete the code to check if the response body contains the expected JSON key.

Postman
pm.test('Response has userId', function () { var jsonData = pm.response.json(); pm.expect(jsonData).to.have.property('[1]'); });
Drag options to blanks, or click blank then click option'
Apassword
Busername
Cemail
DuserId
Attempts:
3 left
💡 Hint
Common Mistakes
Checking for keys that are not present in the response.
3fill in blank
hard

Fix the error in the assertion to correctly check the response status code.

Postman
pm.test('Status code is 201', function () { pm.expect(pm.response.[1]).to.eql(201); });
Drag options to blanks, or click blank then click option'
Acode
Bstatus
CstatusCode
DresponseCode
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect property names like status or statusCode.
4fill in blank
hard

Fill both blanks to create a test that checks if the response time is less than 500 milliseconds.

Postman
pm.test('Response time is fast', function () { pm.expect(pm.response.[1]).to.be.[2](500); });
Drag options to blanks, or click blank then click option'
AresponseTime
Bbelow
Cabove
Dequal
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'above' instead of 'below' for checking response time.
5fill in blank
hard

Fill all three blanks to write a test that verifies the response header 'Content-Type' is 'application/json'.

Postman
pm.test('Content-Type is JSON', function () { pm.expect(pm.response.headers.get('[1]')).to.equal('[2]/[3]'); });
Drag options to blanks, or click blank then click option'
AContent-Type
Bapplication
Cjson
Dcontent-type
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase header name or wrong content type value.