Interview Prep/Python for DevOps/Data formats, HTTP & REST APIs

Which HTTP errors should you retry, and which should you not?

IntermediateConceptData formats, HTTP & REST APIs
Answer

Retry: connection errors, timeouts, 429 (honor Retry-After), 502, 503, 504, and usually 500 for idempotent calls.

Do not retry: 400 (your request is wrong), 401/403 (credentials or permissions; retrying can lock accounts), 404, 409 conflicts (handle explicitly), 422 validation errors.

Retrying non-idempotent POSTs can create duplicates (two deployments, two tickets), unless the API supports an idempotency key header.

All Python for DevOps questions Roadmap: Python for automation

More on Data formats, HTTP & REST APIs