Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 404 which means Not Found.
Using 500 which means Server Error.
✗ Incorrect
The status code 200 means the request was successful.
2fill in blank
mediumComplete the code to verify the response status code is in the 4xx client error range.
Postman
pm.test("Status code is client error", function () { pm.expect(pm.response.code).to.be.[1]; });
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'below(400)' which checks for codes less than 400.
Using 'equal(400)' which only checks for exactly 400.
✗ Incorrect
The 4xx range indicates client errors, so the status code should be between 400 and 499.
3fill in blank
hardFix the error in the code to correctly assert the status code is 201.
Postman
pm.test("Status code is 201", function () { pm.response.to.have.status([1]); });
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around the number making it a string.
Using descriptive text instead of the numeric code.
✗ Incorrect
The status code should be a number, not a string or text.
4fill in blank
hardFill both blanks to check if the status code is either 200 or 204.
Postman
pm.test("Status code is 200 or 204", function () { pm.expect(pm.response.code).to.be.oneOf([[1], [2]]); });
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 201 which means Created, not requested here.
Using 400 which is a client error.
✗ Incorrect
200 means OK and 204 means No Content, both are successful responses.
5fill in blank
hardFill all three blanks to assert the status code is between 200 and 299 inclusive.
Postman
pm.test("Status code is success range", function () { pm.expect(pm.response.code).to.be.within([1], [2]); pm.expect(pm.response.code).to.not.equal([3]); });
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 199 as lower bound which is not a valid success code.
Including 300 which is outside the success range.
✗ Incorrect
The success status codes range from 200 to 299. We exclude 300 which is a redirection.