Google Classroom 外掛程式現已全面開放開發人員使用!詳情請參閱
外掛程式說明文件。
Google Classroom API 錯誤結構
Classroom API 會傳回錯誤資訊,協助開發人員排解問題,並為使用者提供實用的資訊。本指南說明如何剖析從 API 傳回的錯誤資訊。
Classroom API 會傳回兩種層級的錯誤資訊:
- 標頭中的 HTTP 錯誤代碼。
- 回應主體中的物件,其中包含其他詳細資料。
錯誤訊息結構
回應主體中傳回的錯誤包含下列欄位:
code
:數字 HTTP 錯誤代碼。例如 403
。
message
:錯誤的其他詳細資料。如有可用訊息,系統會在錯誤訊息前方加上 @
和特定錯誤類型。例如:@ClassroomApiDisabled
status
:HTTP 要求狀態。例如,PERMISSION_DENIED
或 NOT_FOUND
。
如果要求失敗並顯示 ClassroomApiDisabled
錯誤,回應會是:
{
"error": {
"code": 403,
"message": "@ClassroomApiDisabled The user is not permitted to access the Classroom API.",
"status": "PERMISSION_DENIED"
}
}
您可以使用回應主體來偵錯錯誤原因,並為使用者提供實用的資訊。檢查特定錯誤訊息時,請在結尾加上空格,以免與其他以相同字串開頭的值相符。在提供的錯誤範例中,您可以檢查訊息欄位是否以 "@ClassroomApiDisabled "
開頭,以便向使用者顯示適當的資訊。
請參閱「常見錯誤」頁面,瞭解 Classroom API 可能傳回的部分錯誤。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-01-30 (世界標準時間)。
[null,null,["上次更新時間:2025-01-30 (世界標準時間)。"],[[["The Classroom API provides error information via HTTP error codes in the header and detailed error objects in the response body."],["Error objects in the response body contain a numerical `code`, a detailed `message` potentially including a specific error type prepended with `@`, and an HTTP request `status`."],["Developers can use the error `message` field, particularly by checking for specific prefixes like `@ClassroomApiDisabled `, to debug issues and inform users."],["The error message structure provided by the API allows for the extraction of the HTTP code, the reason behind the error and its status."],["Refer to the Common Errors page to see a detailed list of possible error messages and the actions that can be taken in response to them."]]],[]]