Google Classroom 外掛程式現已全面開放開發人員使用!詳情請參閱
外掛程式說明文件。
Method: userProfiles.guardianInvitations.create
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
建立監護人邀請,並傳送電子郵件給監護人,要求他們確認自己是學生的監護人。
監護人接受邀請後,其 state
會變更為 COMPLETED
,並開始收到監護人通知。系統也會建立 Guardian
資源,用來代表有效的監護人。
要求物件必須設定 studentId
和 invitedEmailAddress
欄位。如果未設定這些欄位,或在要求中設定任何其他欄位,都會導致錯誤。
這個方法會傳回下列錯誤代碼:
PERMISSION_DENIED
如果目前使用者沒有管理監護人的權限、相關監護人已拒絕太多該名學生的要求、相關網域未啟用監護人功能,或發生其他存取錯誤,就會發生此問題。
RESOURCE_EXHAUSTED
學生或家長已超過家長連結上限。
INVALID_ARGUMENT
監護人的電子郵件地址無效 (例如太長),或是系統無法辨識提供的學生證件格式 (不是電子郵件地址,也不是這個 API 中的 userId
)。如果設定唯讀欄位,或將 state
欄位設為 PENDING
以外的值,系統也會傳回這個錯誤。
NOT_FOUND
:如果提供的學生 ID 有效,但 Classroom 沒有該學生的記錄。
ALREADY_EXISTS
如果學生已收到待處理的監護人邀請,且已提供 invitedEmailAddress
,或是已提供的 invitedEmailAddress
與此使用者現有 Guardian
的 Google 帳戶相符。
HTTP 要求
POST https://classroom.googleapis.com/v1/userProfiles/{guardianInvitation.studentId}/guardianInvitations
這個網址使用 gRPC 轉碼語法。
路徑參數
參數 |
guardianInvitation.studentId |
string
學生 ID (標準格式)
|
回應主體
如果成功,回應主體會包含新建立的 GuardianInvitation
例項。
授權範圍
需要下列 OAuth 範圍:
https://www.googleapis.com/auth/classroom.guardianlinks.students
詳情請參閱授權指南。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-25 (世界標準時間)。
[null,null,["上次更新時間:2025-07-25 (世界標準時間)。"],[],[],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)."]]