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-08-29 UTC。
[null,null,["最終更新日 2025-08-29 UTC。"],[],[],null,["# Google Classroom API error structure\n\nThe Classroom API returns error information that can help developers\ndebug issues and provide helpful, actionable information to end users. This\nguide explains how to parse error information returned from the API.\n\nThe Classroom API returns two levels of error information:\n\n- HTTP error code in the header.\n- An object in the response body with additional details.\n\nError message structure\n-----------------------\n\nErrors returned in the response body include the following fields:\n\n- `code`: The numerical HTTP error code. For example, `403`.\n- `message`: Additional details about the error. When available, the error message is prepended with `@` and a specific error type. For example, `@ClassroomApiDisabled`.\n- `status`: The HTTP request status. For example, `PERMISSION_DENIED` or `NOT_FOUND`.\n\nIf a request failed with a [`ClassroomApiDisabled`](/workspace/classroom/troubleshooting/common-errors#classroom-api-disabled) error, the response would\nbe: \n\n {\n \"error\": {\n \"code\": 403,\n \"message\": \"@ClassroomApiDisabled The user is not permitted to access the Classroom API.\",\n \"status\": \"PERMISSION_DENIED\"\n }\n }\n\nYou can use the response body to help you debug the cause of the error and\nprovide helpful information to users. Include a trailing space when checking\nfor a specific error message to avoid matching other values that start with\nthe same string. In the provided error example, you can check if the message\nfield begins with `\"@ClassroomApiDisabled \"` to present appropriate information\nto users.\n\nReference the [Common errors](/workspace/classroom/troubleshooting/common-errors) page for information on some errors that\ncan be returned by the Classroom API."]]