ส่วนเสริมของ 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."]]