Hiện tại, các nhà phát triển đã có thể sử dụng rộng rãi tiện ích bổ sung của Google Lớp học! Vui lòng xem
tài liệu về tiện ích bổ sung để biết thêm thông tin.
Method: userProfiles.guardianInvitations.create
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Tạo lời mời cho người giám hộ và gửi email cho người giám hộ để yêu cầu họ xác nhận rằng họ là người giám hộ của học viên.
Sau khi người giám hộ chấp nhận lời mời, state
của họ sẽ thay đổi thành COMPLETED
và họ sẽ bắt đầu nhận được thông báo dành cho người giám hộ. Một tài nguyên Guardian
cũng sẽ được tạo để đại diện cho người giám hộ đang hoạt động.
Đối tượng yêu cầu phải đặt các trường studentId
và invitedEmailAddress
. Nếu không đặt các trường này hoặc đặt bất kỳ trường nào khác trong yêu cầu, bạn sẽ gặp lỗi.
Phương thức này trả về các mã lỗi sau:
PERMISSION_DENIED
nếu người dùng hiện tại không có quyền quản lý người giám hộ, nếu người giám hộ có liên quan đã từ chối quá nhiều yêu cầu đối với học viên đó, nếu người giám hộ không được bật cho miền có liên quan hoặc đối với các lỗi truy cập khác.
RESOURCE_EXHAUSTED
nếu học viên hoặc người giám hộ đã vượt quá giới hạn liên kết với người giám hộ.
INVALID_ARGUMENT
nếu địa chỉ email của người giám hộ không hợp lệ (ví dụ: nếu địa chỉ email quá dài) hoặc nếu không thể nhận dạng định dạng của thẻ sinh viên được cung cấp (đây không phải là địa chỉ email cũng không phải là userId
từ API này). Lỗi này cũng sẽ được trả về nếu bạn đặt các trường chỉ có thể đọc hoặc nếu bạn đặt trường state
thành một giá trị khác với PENDING
.
NOT_FOUND
nếu mã sinh viên bạn cung cấp là mã sinh viên hợp lệ nhưng Lớp học không có hồ sơ của học viên đó.
ALREADY_EXISTS
nếu đã có lời mời người giám hộ đang chờ xử lý cho học viên và invitedEmailAddress
được cung cấp, hoặc nếu invitedEmailAddress
được cung cấp khớp với Tài khoản Google của Guardian
hiện có cho người dùng này.
Yêu cầu HTTP
POST https://classroom.googleapis.com/v1/userProfiles/{guardianInvitation.studentId}/guardianInvitations
URL sử dụng cú pháp Chuyển mã gRPC.
Tham số đường dẫn
Thông số |
guardianInvitation.studentId |
string
Giấy tờ tuỳ thân của học viên (ở định dạng chuẩn)
|
Nội dung yêu cầu
Nội dung yêu cầu chứa một bản sao của GuardianInvitation
.
Nội dung phản hồi
Nếu thành công, nội dung phản hồi sẽ chứa một thực thể GuardianInvitation
mới tạo.
Phạm vi uỷ quyền
Yêu cầu phạm vi OAuth sau:
https://www.googleapis.com/auth/classroom.guardianlinks.students
Để biết thêm thông tin, hãy xem Hướng dẫn uỷ quyền.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-25 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[],[],null,["# Method: userProfiles.guardianInvitations.create\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nCreates a guardian invitation, and sends an email to the guardian asking them to confirm that they are the student's guardian.\n\nOnce the guardian accepts the invitation, their `state` will change to `COMPLETED` and they will start receiving guardian notifications. A `Guardian` resource will also be created to represent the active guardian.\n\nThe request object must have the `studentId` and `invitedEmailAddress` fields set. Failing to set these fields, or setting any other fields in the request, will result in an error.\n\nThis method returns the following error codes:\n\n- `PERMISSION_DENIED` if the current user does not have permission to manage guardians, if the guardian in question has already rejected too many requests for that student, if guardians are not enabled for the domain in question, or for other [access errors](/workspace/classroom/reference/Access.Errors).\n- `RESOURCE_EXHAUSTED` if the student or guardian has exceeded the guardian link limit.\n- `INVALID_ARGUMENT` if the guardian email address is not valid (for example, if it is too long), or if the format of the student ID provided cannot be recognized (it is not an email address, nor a `userId` from this API). This error will also be returned if read-only fields are set, or if the `state` field is set to to a value other than `PENDING`.\n- `NOT_FOUND` if the student ID provided is a valid student ID, but Classroom has no record of that student.\n- `ALREADY_EXISTS` if there is already a pending guardian invitation for the student and `invitedEmailAddress` provided, or if the provided `invitedEmailAddress` matches the Google account of an existing `Guardian` for this user.\n\n### HTTP request\n\n`POST https://classroom.googleapis.com/v1/userProfiles/{guardianInvitation.studentId}/guardianInvitations`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|--------------------------------|-------------------------------------------------|\n| `guardianInvitation.studentId` | `string` ID of the student (in standard format) |\n\n### Request body\n\nThe request body contains an instance of [GuardianInvitation](/workspace/classroom/reference/rest/v1/userProfiles.guardianInvitations#GuardianInvitation).\n\n### Response body\n\nIf successful, the response body contains a newly created instance of [GuardianInvitation](/workspace/classroom/reference/rest/v1/userProfiles.guardianInvitations#GuardianInvitation).\n\n### Authorization scopes\n\nRequires the following OAuth scope:\n\n- `https://www.googleapis.com/auth/classroom.guardianlinks.students`\n\nFor more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent)."]]