Skip to content

Free guide

Read an API response before you retry

Follow a fictional export request from acceptance to a finished result.

Why it matters

A user presses Export once. A timeout or a slow job should not leave them guessing whether they need to press it again.

Core concepts

Request

The method names the action and the path identifies the resource. The example service accepts an export request and returns a job to check.

Response

In this example the service returns 202 plus a Location header. Its contract defines that URL as the status resource. A later read tells the client whether the file is ready.

Try it step by step

  1. Read the sample exchange. Identify which request starts work and which one checks it.
  2. Draw three screen states: accepted, running and finished. Add the failure state and the message you would show.
  3. Suppose the first response never reaches the client. Check the contract for a stable request key or lookup before submitting the work again.

Write the method, path, expected status and next action in four columns.

Worked example

The server accepted the export and returned job 42. A second POST would ask to start work again. A GET to the returned status URL lets the client follow this specific run.

Illustrative HTTP exchange
POST /exports
→ 202 Accepted
  Location: /exports/42

GET /exports/42
→ 200 OK
  {"state":"running"}

GET /exports/42
→ 200 OK
  {"state":"complete","file":"/files/export-42.csv"}

Common mistake

Assuming every service that returns 202 offers a status URL. Read the contract for that service.

Practice exercise

Change the example to a failed job. Design a message that helps the operator distinguish retrying a status check from starting a new export.

Check your understanding

Which request checks the original export in this example?

  1. POST /exports
  2. GET /exports/42
  3. POST /exports/42/retry
Show answer

GET /exports/42. A response tells you what the server can confirm at that moment. Read the contract before choosing the next request.

Takeaway

A response tells you what the server can confirm at that moment. Read the contract before choosing the next request.

Browse more lessons