狀態回應代碼
下列狀態碼可在 HTTP 回應中傳回。
HTTP 代碼 |
HTTP 說明 |
附註 |
2xx |
確定 |
非錯誤;於成功時傳回。這也應用於商業邏輯失敗 (例如 CreateBookingResponse 中的 booking_failure 已填入) |
400 |
要求無效 |
要求無效/引數無效 (找不到商家、服務、時段、嘗試預訂無效的時段、取消不存在的預訂)。 |
401 |
未授權 |
未驗證 (憑證無效,需要重新登入);要求沒有該作業的有效驗證憑證。 |
403 |
禁止存取 |
權限遭拒/禁止 (拒絕了已知的呼叫端)。對於因耗用某些資源所導致的拒絕情形,不得使用這項回應 (請針對這些錯誤改用 Too Many Requests )。如果無法識別呼叫端,請勿使用 Forbidden (若發生這類錯誤,請改用 Unauthorized )。 |
404 |
找不到 |
找不到,例如無法找到資源、網址無效,或是包含無效的遠端程序呼叫 (RPC)。 |
409 |
衝突 |
作業已取消,原因通常是排序器檢查失敗或交易取消等並行問題。 |
429 |
要求數超量 |
已耗盡某些資源 (可能是每位使用者的配額,也可能是整個檔案系統的空間不足)。 |
499 |
用戶端已結束要求 |
作業已取消 (通常由呼叫端取消)。 |
500 |
內部伺服器錯誤 |
發生內部錯誤,這表示基礎系統預期的某些不變量已遭破壞。此錯誤代碼僅在發生嚴重錯誤時使用。 |
501 |
未執行 |
未實作該作業,或在此服務中不支援/未啟用該作業。 |
503 |
無法使用服務 |
服務目前無法使用。這很可能是暫時性問題,可透過重試輪詢來解決。 |
504 |
閘道逾時 |
已超過期限,但作業尚未完成。針對會變更系統狀態的作業,即使作業順利完成也有可能會傳回這個錯誤,舉例來說,雖然伺服器成功提供回應,但因為延遲時間過長而導致超過期限。 |
有時可能適用多個錯誤代碼。在這類情況下,服務應傳回最適當的明確錯誤代碼。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-11-26 (世界標準時間)。
[null,null,["上次更新時間:2024-11-26 (世界標準時間)。"],[[["HTTP status codes indicate the outcome of a request, ranging from success (2xx) to various error types."],["Client errors (4xx) signal issues like bad requests, authentication failures, or missing resources."],["Server errors (5xx) represent problems on the server side, such as internal errors or service unavailability."],["Specific error codes provide detailed information about the nature of the problem, enabling appropriate action."],["When multiple error codes could apply, the most specific one should be used."]]],["HTTP responses can include various status codes. Successful operations return a 2xx code. Client-side errors include 400 (Bad Request), 401 (Unauthorized), 403 (Forbidden), 404 (Not Found), 409 (Conflict), 429 (Too Many Requests), and 499 (Client Closed Request). Server-side errors are 500 (Internal Server Error), 501 (Not Implemented), 503 (Service Unavailable), and 504 (Gateway Timeout). The most specific error code should be returned when multiple codes apply.\n"]]