0
0
Postmantesting~10 mins

GET 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 send a GET request to the URL.

Postman
pm.sendRequest({ url: '[1]', method: 'GET' }, function (err, res) { pm.expect(err).to.be.null; });
Drag options to blanks, or click blank then click option'
A'https://api.example.com/data'
B'POST'
C'https://api.example.com/post'
D'DELETE'
Attempts:
3 left
💡 Hint
Common Mistakes
Using HTTP methods like 'POST' or 'DELETE' instead of the URL string.
Not putting the URL inside quotes.
2fill in blank
medium

Complete the code to check the response status is 200.

Postman
pm.sendRequest('https://api.example.com/data', function (err, res) { pm.expect(res.status).to.equal([1]); });
Drag options to blanks, or click blank then click option'
A404
B200
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 parse JSON response body.

Postman
pm.sendRequest('https://api.example.com/data', function (err, res) { let data = res.[1](); pm.expect(data).to.be.an('object'); });
Drag options to blanks, or click blank then click option'
Aparse
Btext
Cbody
Djson
Attempts:
3 left
💡 Hint
Common Mistakes
Using text() returns raw text, not parsed JSON.
Trying to access body() which is not a method.
4fill in blank
hard

Fill both blanks to check the response has a JSON property 'name' with value 'John'.

Postman
pm.sendRequest('https://api.example.com/user', function (err, res) { let data = res.[1](); pm.expect(data).to.have.property('[2]', 'John'); });
Drag options to blanks, or click blank then click option'
Ajson
Btext
Cname
Dage
Attempts:
3 left
💡 Hint
Common Mistakes
Using text() instead of json().
Checking wrong property like 'age' instead of 'name'.
5fill in blank
hard

Fill all three blanks to send a GET request, parse JSON, and assert the 'status' is 'success'.

Postman
pm.sendRequest({ url: [1], method: '[2]' }, function (err, res) { let result = res.[3](); pm.expect(result.status).to.equal('success'); });
Drag options to blanks, or click blank then click option'
A'https://api.example.com/status'
BGET
Cjson
DPOST
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST method instead of GET.
Not parsing JSON before accessing properties.
Using wrong URL or missing quotes.