0
0
Postmantesting~10 mins

First API request 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'
AGET
BPOST
CPUT
DDELETE
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST instead of GET for a simple data retrieval request.
Forgetting to put the method name in quotes.
2fill in blank
medium

Complete the code to check if the response status code is 200.

Postman
pm.test('Status code is 200', function () { pm.response.to.have.status([1]); });
Drag options to blanks, or click blank then click option'
A404
B201
C200
D500
Attempts:
3 left
💡 Hint
Common Mistakes
Using 201 which means resource created, not a simple success.
Using quotes around the number, which causes the test to fail.
3fill in blank
hard

Fix the error in the code to parse JSON response body correctly.

Postman
let data = pm.response.json()[1];
Drag options to blanks, or click blank then click option'
A;
B.json()
C()
D{}
Attempts:
3 left
💡 Hint
Common Mistakes
Adding extra parentheses after the method call.
Trying to access .json() again after calling pm.response.json().
4fill in blank
hard

Fill both blanks to assert the response body contains a property 'success' with value true.

Postman
pm.test('Response has success true', function () { pm.expect(pm.response.json().[1]).to.eql([2]); });
Drag options to blanks, or click blank then click option'
Asuccess
Btrue
Cfalse
Dstatus
Attempts:
3 left
💡 Hint
Common Mistakes
Using string 'true' instead of boolean true.
Checking for property 'status' instead of 'success'.
5fill in blank
hard

Fill all three blanks to test that the response header 'Content-Type' includes 'application/json'.

Postman
pm.test('Content-Type is JSON', function () { pm.expect(pm.response.headers.get('[1]')).to.include('[2]'); pm.expect(pm.response.headers.has('[3]')).to.be.true; });
Drag options to blanks, or click blank then click option'
AContent-Type
Bapplication/json
Ccontent-type
DAccept
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'content-type' which may not match header name exactly.
Checking for header 'Accept' instead of 'Content-Type'.