מבנה השגיאות של 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"
}
}
אפשר להשתמש בגוף התגובה כדי לנפות באגים ולמצוא את הגורם לשגיאה, וכדי לספק למשתמשים מידע שימושי. אם מחפשים הודעת שגיאה ספציפית, צריך להוסיף רווח בסוף כדי למנוע התאמה לערכים אחרים שמתחילים באותה מחרוזת. בדוגמה לשגיאה שצוינה, אפשר לבדוק אם השדה message מתחיל ב-"@ClassroomApiDisabled "
כדי להציג למשתמשים את המידע המתאים.
בדף שגיאות נפוצות יש מידע על חלק מהשגיאות שיכולות להיות מוחזרות על ידי Classroom API.
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 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."]]