I am testing an API with postman using simple GET, POST, and PUT requests. I have only 2 variables in the header each time (content-type and user) and am using a simple raw json script in the body when I run POST. Currently I only get 2-3 HTTP status response codes, 200 OK for success and 400 (bad request if I don't have the body info) and 404 if the URL is not correct. But I need to test multiple HTTP requests (201 Created, 202 Accepted, etc..) and I can't figure out how to trigger a specific response code. Using 201 as an example, I am using a test script like such: tests["Status code is 201 Created"] = responseCode.code === 201;
Other than that, what do I need to do to trigger that specific response code? The HTTP/Semantics and Content doc says, the following but it doesn't make sense to me;
The 201 (Created) status code indicates that the request has been fulfilled and has resulted in one or more new resources being created. The primary resource created by the request is identified by either a Location header field in the response or, if no Location field is received, by the effective request URI. The 201 response payload typically describes and links to the resource(s) created. See Section 7.2 for a discussion of the meaning and purpose of validator header fields, such as ETag and Last-Modified, in a 201 response.
describe('response', function() {
it('status must be OK', function() {
response.should.have.status(200);
response.should.not.be.empty;
});
});
You can chage this line ex. with: response.should.have.status(201);
I hope help you with the examples.