Google Classroom アドオンの一般提供が開始されました。詳しくは、
アドオンのドキュメントをご覧ください。
Google Classroom API のエラー構造
Classroom API は、デベロッパーが問題をデバッグし、エンドユーザーに役立つ実用的な情報を提供するために役立つエラー情報を返します。このガイドでは、API から返されたエラー情報を解析する方法について説明します。
Classroom API は、次の 2 つのレベルのエラー情報を返します。
- ヘッダーの 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 から返される可能性のあるエラーについては、一般的なエラーのページをご覧ください。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-01-30 UTC。
[null,null,["最終更新日 2025-01-30 UTC。"],[[["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."]]],[]]