Co powinien zawierać błąd HTTP, który można ponowić?
„Spróbuj później” nie wystarczy. Klient musi wiedzieć, czy problem jest tymczasowy, kiedy ponowić próbę i czy pierwsza próba wywołała skutek. Użyj statusu i Retry-After oraz rozszerzeń Problem Details specyficznych dla API.
„Spróbuj później” nie wystarczy. Klient musi wiedzieć, czy problem jest tymczasowy, kiedy ponowić próbę i czy pierwsza próba wywołała skutek. Użyj statusu i Retry-After oraz rozszerzeń Problem Details specyficznych dla API.
HTTP/1.1 503 Service Unavailable
Retry-After: 5
Content-Type: application/problem+json
{
"type": "https://api.example.com/problems/temporarily-unavailable",
"title": "Service temporarily unavailable",
"status": 503,
"detail": "The request was not accepted. Retry after the indicated delay.",
"instance": "urn:request:01JEXAMPLE",
"retryable": true,
"operation_result": "not_applied",
"request_id": "01JEXAMPLE"
}Recommended fields and retry safety
503 oznacza tymczasową niedostępność, 429 limit żądań. Retry-After podaje sekundy oczekiwania lub datę HTTP. Decyzje opieraj na stabilnym type lub udokumentowanym kodzie, nie parsuj swobodnego detail. retryable i operation_result to rozszerzenia API, nie pola standardu RFC.
Sources
[RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html)
[RFC 6585](https://www.rfc-editor.org/rfc/rfc6585.html)
[RFC 9457](https://www.rfc-editor.org/rfc/rfc9457.html)