افزونه های 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 برگردانده شود، به صفحه خطاهای رایج مراجعه کنید.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی."],[],[],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."]]