ส่วนเสริมของ Google Classroom พร้อมให้บริการแก่นักพัฒนาซอฟต์แวร์แล้ว โปรดดูข้อมูลเพิ่มเติมใน
เอกสารส่วนเสริม
Method: courses.students.create
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เพิ่มผู้ใช้เป็นนักเรียนของหลักสูตร
ผู้ดูแลระบบโดเมนได้รับอนุญาตให้เพิ่มผู้ใช้ภายในโดเมนของตนเป็นนักเรียนในหลักสูตรภายในโดเมนได้โดยตรง นักเรียนสามารถเพิ่มตนเองลงในหลักสูตรได้โดยใช้รหัสการลงทะเบียน
วิธีการนี้จะแสดงรหัสข้อผิดพลาดต่อไปนี้
PERMISSION_DENIED
หากผู้ใช้ที่ส่งคำขอไม่ได้รับอนุญาตให้สร้างนักเรียนในหลักสูตรนี้ หรือมีข้อผิดพลาดในการเข้าถึง
NOT_FOUND
หากรหัสหลักสูตรที่ขอไม่มีอยู่
FAILED_PRECONDITION
หากบัญชีของผู้ใช้ที่ขอถูกปิดใช้ ข้อผิดพลาดเกี่ยวกับคำขอต่อไปนี้จะปรากฏขึ้น
- CourseMemberLimitReached
- CourseNotModifiable
- UserGroupsMembershipLimitReached
- InactiveCourseOwner
ALREADY_EXISTS
หากผู้ใช้เป็นนักเรียนหรือครูในหลักสูตรอยู่แล้ว
คำขอ HTTP
POST https://classroom.googleapis.com/v1/courses/{courseId}/students
URL ใช้ไวยากรณ์การแปลง gRPC
พารามิเตอร์เส้นทาง
พารามิเตอร์ |
courseId |
string
ตัวระบุของหลักสูตรที่จะสร้างนักเรียน ตัวระบุนี้อาจเป็นตัวระบุที่ Classroom กำหนดหรือ alias ก็ได้
|
พารามิเตอร์การค้นหา
พารามิเตอร์ |
enrollmentCode |
string
รหัสการลงทะเบียนของหลักสูตรที่จะสร้างนักเรียน ต้องใช้รหัสนี้หาก userId สอดคล้องกับผู้ใช้ที่ส่งคำขอ แต่อาจไม่ใช้ก็ได้หากผู้ใช้ที่ส่งคำขอมีสิทธิ์ระดับผู้ดูแลระบบในการสร้างนักเรียนให้กับผู้ใช้รายใดก็ได้
|
เนื้อความของคำขอ
เนื้อความของคำขอมีอินสแตนซ์ของ Student
เนื้อหาการตอบกลับ
หากทำสำเร็จ เนื้อหาการตอบกลับจะมีอินสแตนซ์ Student
ที่สร้างขึ้นใหม่
ขอบเขตการให้สิทธิ์
ต้องใช้ขอบเขต OAuth ต่อไปนี้
https://www.googleapis.com/auth/classroom.rosters
https://www.googleapis.com/auth/classroom.profile.emails
https://www.googleapis.com/auth/classroom.profile.photos
ดูข้อมูลเพิ่มเติมได้ที่คู่มือการให้สิทธิ์
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 UTC
[null,null,["อัปเดตล่าสุด 2025-07-25 UTC"],[],[],null,["# Method: courses.students.create\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Query parameters](#body.QUERY_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nAdds a user as a student of a course.\n\nDomain administrators are permitted to [directly add](https://developers.google.com/workspace/classroom/guides/manage-users) users within their domain as students to courses within their domain. Students are permitted to add themselves to a course using an enrollment code.\n\nThis method returns the following error codes:\n\n- `PERMISSION_DENIED` if the requesting user is not permitted to create students in this course or for [access errors](/workspace/classroom/reference/Access.Errors).\n- `NOT_FOUND` if the requested course ID does not exist.\n- `FAILED_PRECONDITION` if the requested user's account is disabled, for the following [request errors](/workspace/classroom/reference/Request.Errors):\n - CourseMemberLimitReached\n - CourseNotModifiable\n - UserGroupsMembershipLimitReached\n - InactiveCourseOwner\n- `ALREADY_EXISTS` if the user is already a student or teacher in the course.\n\n### HTTP request\n\n`POST https://classroom.googleapis.com/v1/courses/{courseId}/students`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `courseId` | `string` Identifier of the course to create the student in. This identifier can be either the Classroom-assigned identifier or an [alias](/workspace/classroom/reference/rest/v1/courses.aliases#CourseAlias). |\n\n### Query parameters\n\n| Parameters ||\n|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `enrollmentCode` | `string` Enrollment code of the course to create the student in. This code is required if [userId](/workspace/classroom/reference/rest/v1/courses.students#Student.FIELDS.user_id) corresponds to the requesting user; it may be omitted if the requesting user has administrative permissions to create students for any user. |\n\n### Request body\n\nThe request body contains an instance of [Student](/workspace/classroom/reference/rest/v1/courses.students#Student).\n\n### Response body\n\nIf successful, the response body contains a newly created instance of [Student](/workspace/classroom/reference/rest/v1/courses.students#Student).\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/classroom.rosters`\n- `\n https://www.googleapis.com/auth/classroom.profile.emails`\n- `\n https://www.googleapis.com/auth/classroom.profile.photos`\n\nFor more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent)."]]