Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using HTTP methods like 'POST' or 'DELETE' instead of the URL string.
Not putting the URL inside quotes.
✗ Incorrect
The URL must be a valid string for the GET request. Option A is the correct URL string.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 404 which means not found.
Using 500 which means server error.
✗ Incorrect
Status code 200 means the GET request was successful.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
text() returns raw text, not parsed JSON.Trying to access
body() which is not a method.✗ Incorrect
The method json() parses the response body as JSON.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
text() instead of json().Checking wrong property like 'age' instead of 'name'.
✗ Incorrect
Use json() to parse the response and check the property 'name'.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST method instead of GET.
Not parsing JSON before accessing properties.
Using wrong URL or missing quotes.
✗ Incorrect
The URL is the API endpoint, method is GET, and json() parses the response.