title: HTTP and REST: Are Status Codes Relevant to the Request, or the Resource?
body: <p>In REST using HTTP, are status codes relevant to the <em>request</em>, or the <em>resource</em>?</p>
  <p>In non-REST HTTP request/response calls, the status code refers to the success/failure/etc <em>of the request being made</em>. Did the request fail because the client sent an invalid request? Then return 400, and so on.</p>
  <p>But with REST, the URI is stated to refer to a &quot;resource&quot;, and the status code often appears to be used to refer to the resource (i.e. it's metadata about the resource). But if the request to retrieve the resource fails, how does the client know if there's a problem with the resource, or just a problem with the request to GET the resource?</p>
  <p>My question is - have I understood that correctly? And if so, what happens if the <em>request</em> fails server-side?</p>
  <h2>Example:</h2>
  <ul>
  <li>Client calls <code>POST /api/order/</code> with a payload.</li>
  <li>Server validates the request and enqueues it before immediately returning <code>202 Accepted</code> with <code>Location: /api/order/43573/status</code> and <code>Retry-After: 60</code>.</li>
  <li>Client waits the requisite 60 seconds before polling <code>GET /api/order/43573/status</code>.</li>
  <li>Server returns <code>202 Accepted</code>, including a payload with more information and <code>Retry-After: 60</code>.</li>
  <li>(The waiting and polling continues until processing completes.)</li>
  <li>One of two things happens:
  <ul>
  <li><strong>Success</strong>
  <ul>
  <li>Background processing succeeds.</li>
  <li>Client polls <code>GET /api/order/43573/status</code>.</li>
  <li>Server returns <code>303 See Other</code>, with <code>Location: /api/order/43573</code>.</li>
  <li>Client calls <code>GET /api/order/43573</code>.</li>
  <li>Server returns <code>200 OK</code> with appropriate payload.</li>
  </ul>
  </li>
  <li><strong>Failure</strong>
  <ul>
  <li>Background processing fails for some reason.</li>
  <li>Client polls <code>GET /api/order/43573/status</code>.</li>
  <li>Server returns <code>200 See Other</code>, with payload indicating failure.</li>
  </ul>
  </li>
  </ul>
  </li>
  </ul>
  <p>My problem is that last request - returning <code>200 OK</code> seems right for the web request, but the only body it'll ever contain is information about failure.</p>