Complete the code to check if the response status code is 200.
pm.test("Status code is 200", function () { pm.response.to.have.status([1]); });
The status code 200 means the request was successful.
Complete the code to verify the response status code is in the 4xx client error range.
pm.test("Status code is client error", function () { pm.expect(pm.response.code).to.be.[1]; });
The 4xx range indicates client errors, so the status code should be between 400 and 499.
Fix the error in the code to correctly assert the status code is 201.
pm.test("Status code is 201", function () { pm.response.to.have.status([1]); });
The status code should be a number, not a string or text.
Fill both blanks to check if the status code is either 200 or 204.
pm.test("Status code is 200 or 204", function () { pm.expect(pm.response.code).to.be.oneOf([[1], [2]]); });
200 means OK and 204 means No Content, both are successful responses.
Fill all three blanks to assert the status code is between 200 and 299 inclusive.
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]); });
The success status codes range from 200 to 299. We exclude 300 which is a redirection.
