Testing 202 Accepted and async job polling

202 Accepted is the status clients mishandle most, because it is a success response for work that has not happened. The Protocol Lab models the full pattern: submit, receive a 202 with a status URL, poll until the job resolves, and handle the job that fails rather than completes.

Async job testing — request and response sequence Sequence diagram for Async job testing: POST /protocol/v1/jobs answers 202 Accepted. GET /protocol/v1/jobs/{id} answers 200 OK. GET /protocol/v1/maintenance answers 503 Service Unavailable. GET /protocol/v1/gateway-timeout answers 504 Gateway Timeout. Your client Fun API Playground POST /protocol/v1/jobs 202 Accepted Accepted. Poll the Location header until status is "done". GET /protocol/v1/jobs/{id} 200 OK queued → running → done, advancing each time you poll GET /protocol/v1/maintenance 503 Service Unavailable Always, with a Retry-After header. Good retry/backoff pra… GET /protocol/v1/gateway-timeout 504 Gateway Timeout Always, after ~3 seconds. Pair it with a 2s client timeou…
Real endpoints from the catalog — every request above is served, and every status code shown is one that endpoint actually returns.

How to practise it

  1. Submit a job, read the Location header from the 202, and poll it rather than assuming the work is done.
  2. Poll with a sensible interval and a ceiling — a tight loop against a job that never finishes is its own outage.
  3. Handle the job that completes with a failure: the poll succeeded, the work did not.
  4. Check what your client does when the job outlives your overall timeout.
  5. Combine with the 503 and 504 endpoints to see polling behave under an unreliable upstream.

APIs to try it on

Status codes involved

Other techniques

Getting started guide · All 39 mock REST APIs

Last updated