Search code examples
httpresthttp-status-codeshttp-redirecthttp-status-code-303

Is HTTP 303 acceptable for other HTTP methods?


RESTful Web Services encourages the use of HTTP 303 to redirect clients to the canonical representation of a resource. It only discusses topic in the context of HTTP GET.

Does this apply to other HTTP methods as well? If a client attempts a HTTP PUT or DELETE to a non-canonical URI, is it acceptable (and/or recommended) to return HTTP 303? What is the best practice and why?


Solution

  • This status code is generally applicable to any HTTP method. It is primarily used to allow the output of a POST action to redirect the user agent to a selected resource, since doing so provides the information corresponding to the POST response in a form that can be separately identified, bookmarked, and cached independent of the original request.

    Source: https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-p2-semantics-21#section-7.4.4