views:

240

answers:

2

I'm developing a RESTful API and have a question about the most appropriate response status codes for certain scenarios.

Consider the case where the client makes a GET request for a resource. How can I disambiguate a "not found" response for the case where the resource legitimately does not exist, vs. the case where there may be a minor service interruption (during deployment, etc).

+5  A: 

Send a 404 status code for "Not found"

Send some 500-series error for error conditions on the server-side.

timdev
+6  A: 

The W3C defines very specific status codes for nearly all cases you can think of. For your specific needs:

  • Not Found: 404
  • Service Unavailable: 503
SingleShot