Google 课堂插件现已面向开发者正式推出!如需了解详情,请参阅
插件文档。
Method: invitations.create
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
创建邀请。同一用户和课程之间只能存在一个邀请。删除并重新创建邀请,以进行更改。
此方法会返回以下错误代码:
PERMISSION_DENIED
,如果系统不允许请求的用户为此课程创建邀请,或者因访问权限错误而无法创建邀请。
- 如果课程或用户不存在,则为
NOT_FOUND
。
FAILED_PRECONDITION
:
- 请求的用户的账号已停用。
- 如果用户已拥有此角色或权限更高的角色。
- 以下请求错误:
- 如果已向指定用户发送了课程邀请,则为
ALREADY_EXISTS
;否则为 0。
HTTP 请求
POST https://classroom.googleapis.com/v1/invitations
网址采用 gRPC 转码语法。
请求正文
请求正文包含一个 Invitation
实例。
响应正文
如果成功,响应正文将包含一个新创建的 Invitation
实例。
授权范围
需要以下 OAuth 范围:
https://www.googleapis.com/auth/classroom.rosters
如需了解详情,请参阅授权指南。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[],[],null,["# Method: invitations.create\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nCreates an invitation. Only one invitation for a user and course may exist at a time. Delete and re-create an invitation to make changes.\n\nThis method returns the following error codes:\n\n- `PERMISSION_DENIED` if the requesting user is not permitted to create invitations for this course or for [access errors](/workspace/classroom/reference/Access.Errors).\n- `NOT_FOUND` if the course or the user does not exist.\n- `FAILED_PRECONDITION`:\n - if the requested user's account is disabled.\n - if the user already has this role or a role with greater permissions.\n - for the following [request errors](/workspace/classroom/reference/Request.Errors):\n - IneligibleOwner\n- `ALREADY_EXISTS` if an invitation for the specified user and course already exists.\n\n### HTTP request\n\n`POST https://classroom.googleapis.com/v1/invitations`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Request body\n\nThe request body contains an instance of [Invitation](/workspace/classroom/reference/rest/v1/invitations#Invitation).\n\n### Response body\n\nIf successful, the response body contains a newly created instance of [Invitation](/workspace/classroom/reference/rest/v1/invitations#Invitation).\n\n### Authorization scopes\n\nRequires the following OAuth scope:\n\n- `https://www.googleapis.com/auth/classroom.rosters`\n\nFor more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent)."]]