Оптимизируйте свои подборки
Сохраняйте и классифицируйте контент в соответствии со своими настройками.
API Classroom возвращает информацию об ошибках, которая может помочь разработчикам устранять неполадки и предоставлять конечным пользователям полезную и применимую на практике информацию. В этом руководстве объясняется, как анализировать информацию об ошибках, возвращаемую API.
API Classroom возвращает два уровня информации об ошибках:
Код ошибки HTTP в заголовке.
Объект в теле ответа с дополнительными сведениями.
Структура сообщения об ошибке
Ошибки, возвращаемые в теле ответа, включают следующие поля:
code : числовой код ошибки HTTP. Например, 403 .
message : Дополнительные сведения об ошибке. Если доступно, сообщение об ошибке начинается с @ и указывается тип ошибки. Например, @ClassroomApiDisabled .
status : статус HTTP-запроса. Например, PERMISSION_DENIED или NOT_FOUND .
{"error":{"code":403,"message":"@ClassroomApiDisabled The user is not permitted to access the Classroom API.","status":"PERMISSION_DENIED"}}
Вы можете использовать тело ответа для отладки причины ошибки и предоставления пользователям полезной информации. Добавляйте завершающий пробел при проверке конкретного сообщения об ошибке, чтобы избежать сопоставления с другими значениями, начинающимися с той же строки. В приведённом примере ошибки вы можете проверить, начинается ли поле сообщения с "@ClassroomApiDisabled " , чтобы предоставить пользователям необходимую информацию.
Информацию о некоторых ошибках, которые может возвращать API Classroom, можно найти на странице «Распространенные ошибки» .
[[["Прост для понимания","easyToUnderstand","thumb-up"],["Помог мне решить мою проблему","solvedMyProblem","thumb-up"],["Другое","otherUp","thumb-up"]],[["Отсутствует нужная мне информация","missingTheInformationINeed","thumb-down"],["Слишком сложен/слишком много шагов","tooComplicatedTooManySteps","thumb-down"],["Устарел","outOfDate","thumb-down"],["Проблема с переводом текста","translationIssue","thumb-down"],["Проблемы образцов/кода","samplesCodeIssue","thumb-down"],["Другое","otherDown","thumb-down"]],["Последнее обновление: 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."]]