ข้อผิดพลาด HTTP ที่ลองซ้ำได้ควรมีข้อมูลอะไร
คำว่า “ลองใหม่ภายหลัง” ยังไม่พอ ไคลเอนต์ต้องรู้ว่าปัญหาเกิดชั่วคราวหรือไม่ ควรลองอีกครั้งเมื่อใด และคำขอครั้งแรกมีผลแล้วหรือยัง ใช้ status กับ Retry-After และส่วนขยาย Problem Details เฉพาะ API
คำว่า “ลองใหม่ภายหลัง” ยังไม่พอ ไคลเอนต์ต้องรู้ว่าปัญหาเกิดชั่วคราวหรือไม่ ควรลองอีกครั้งเมื่อใด และคำขอครั้งแรกมีผลแล้วหรือยัง ใช้ status กับ Retry-After และส่วนขยาย Problem Details เฉพาะ 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 หมายถึงไม่พร้อมใช้งานชั่วคราว ส่วน 429 หมายถึงเกินขีดจำกัด Retry-After ระบุเวลารอเป็นวินาทีหรือวันที่ HTTP ให้ตัดสินใจจาก type ที่คงที่หรือรหัสที่มีเอกสาร อย่าแยกวิเคราะห์ detail ที่เป็นข้อความอิสระ retryable และ operation_result เป็นส่วนขยายของ API ไม่ใช่ฟิลด์มาตรฐาน 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)