Search code examples
resthttphttpshttp-status-code-403

Can GET request message ever return a HTTP status code of 201?


Can a GET request message ever return a HTTP status code of 201?


Solution

  • A conforming HTTP server should never do this. GET is a safe method, and is not supposed to have any side effects.

    201 means a new resource was created on the server, which really is a side-effect.

    So if a GET results in a 201, something is wrong. However, if you are building a client want to know in advance which success codes you might get, you should simply support every code between 200 and 299 (inclusive) and treat them all as success codes.