0
0
Postmantesting~10 mins

Example requests and responses 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 GET in Postman.

Postman
pm.request.method = '[1]';
Drag options to blanks, or click blank then click option'
APOST
BGET
CPUT
DDELETE
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST instead of GET when only retrieving data.
Confusing HTTP methods and setting the wrong one.
2fill in blank
medium

Complete the code to check if the response status code is 200 in Postman test script.

Postman
pm.test('Status code is 200', function () { pm.response.to.have.status([1]); });
Drag options to blanks, or click blank then click option'
A200
B404
C500
D201
Attempts:
3 left
💡 Hint
Common Mistakes
Using 404 which means Not Found.
Using 500 which means server error.
3fill in blank
hard

Fix the error in the code to correctly check if the response body contains the string 'success'.

Postman
pm.test('Body contains success', function () { pm.expect(pm.response.text()).to.[1]('success'); });
Drag options to blanks, or click blank then click option'
AtoBe
BtoEqual
Ccontain
DtoHaveLength
Attempts:
3 left
💡 Hint
Common Mistakes
Using toBe or toEqual which require exact matches.
Using toHaveLength which checks length, not content.
4fill in blank
hard

Fill both blanks to parse JSON response and check if the 'status' field equals 'ok'.

Postman
let jsonData = pm.response.[1](); pm.test('Status is ok', function () { pm.expect(jsonData.[2]).to.eql('ok'); });
Drag options to blanks, or click blank then click option'
Ajson
Btext
Cstatus
Dbody
Attempts:
3 left
💡 Hint
Common Mistakes
Using pm.response.text() which returns raw string, not parsed JSON.
Accessing a wrong field name.
5fill in blank
hard

Fill all three blanks to write a test that checks if the response JSON has a 'data' array with length greater than 0.

Postman
let jsonData = pm.response.[1](); pm.test('Data array is not empty', function () { pm.expect(jsonData.[2].[3]).to.be.above(0); });
Drag options to blanks, or click blank then click option'
Ajson
Bdata
Clength
Dtext
Attempts:
3 left
💡 Hint
Common Mistakes
Using pm.response.text() instead of json().
Checking the array itself instead of its length.
Using wrong property names.