Google Classroom 外掛程式現已全面開放開發人員使用!詳情請參閱
外掛程式說明文件。
Method: registrations.create
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
建立 Registration
,讓 Classroom 開始傳送通知,從提供的 feed
傳送至 cloudPubSubTopic
中提供的目的地。
傳回已建立的 Registration
。目前,這會與引數相同,但會填入伺服器指派的欄位,例如 expiryTime
和 id
。
請注意,系統會忽略 expiryTime
或 id
欄位中指定的任何值。
雖然 Classroom 會盡力驗證 cloudPubSubTopic
並傳回錯誤,但呼叫端有責任確保 cloudPubSubTopic
存在,且 Classroom 有權發布至該位置。
這個方法可能會傳回以下錯誤代碼:
PERMISSION_DENIED
如果:
- 已驗證的使用者沒有權限接收所要求欄位的通知。
- 目前的使用者未授予目前 Cloud 專案的存取權,且該專案的範圍不符合要求的動態饋給。請注意,系統目前不支援全網域委派權限的功能。如果要求具有適當的範圍,但沒有授權,系統會傳回 [要求錯誤][
@MissingGrant
錯誤]。
- 發生其他存取錯誤。
INVALID_ARGUMENT
如果:
- 未指定
cloudPubsubTopic
,或指定的 cloudPubsubTopic
無效;或
- 未指定
feed
,或是指定的 feed
無效。
NOT_FOUND
如果:
- 無法找到指定的
feed
,或是要求使用者沒有權限判斷該 feed
是否存在;
- 無法找到指定的
cloudPubsubTopic
,或是 Classroom 未獲得發布至該 cloudPubsubTopic
的權限。
HTTP 要求
POST https://classroom.googleapis.com/v1/registrations
這個網址使用 gRPC 轉碼語法。
要求主體
要求主體包含 Registration
的例項。
回應主體
如果成功,回應主體會包含新建立的 Registration
例項。
授權範圍
需要下列 OAuth 範圍:
https://www.googleapis.com/auth/classroom.push-notifications
詳情請參閱授權指南。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-25 (世界標準時間)。
[null,null,["上次更新時間:2025-07-25 (世界標準時間)。"],[],[],null,["# Method: registrations.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\nCreates a `Registration`, causing Classroom to start sending notifications from the provided `feed` to the destination provided in `cloudPubSubTopic`.\n\nReturns the created `Registration`. Currently, this will be the same as the argument, but with server-assigned fields such as `expiryTime` and `id` filled in.\n\nNote that any value specified for the `expiryTime` or `id` fields will be ignored.\n\nWhile Classroom may validate the `cloudPubSubTopic` and return errors on a best effort basis, it is the caller's responsibility to ensure that it exists and that Classroom has permission to publish to it.\n\nThis method may return the following error codes:\n\n- `PERMISSION_DENIED` if:\n - the authenticated user does not have permission to receive notifications from the requested field; or\n - the current user has not granted access to the current Cloud project with the appropriate scope for the requested feed. Note that domain-wide delegation of authority is not currently supported for this purpose. If the request has the appropriate scope, but no grant exists, a \\[Request Errors\\]\\[`@MissingGrant` error\\] is returned.\n - another [access error](/workspace/classroom/reference/Access.Errors) is encountered.\n- `INVALID_ARGUMENT` if:\n - no `cloudPubsubTopic` is specified, or the specified `cloudPubsubTopic` is not valid; or\n - no `feed` is specified, or the specified `feed` is not valid.\n- `NOT_FOUND` if:\n - the specified `feed` cannot be located, or the requesting user does not have permission to determine whether or not it exists; or\n - the specified `cloudPubsubTopic` cannot be located, or Classroom has not been granted permission to publish to it.\n\n### HTTP request\n\n`POST https://classroom.googleapis.com/v1/registrations`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Request body\n\nThe request body contains an instance of [Registration](/workspace/classroom/reference/rest/v1/registrations#Registration).\n\n### Response body\n\nIf successful, the response body contains a newly created instance of [Registration](/workspace/classroom/reference/rest/v1/registrations#Registration).\n\n### Authorization scopes\n\nRequires the following OAuth scope:\n\n- `https://www.googleapis.com/auth/classroom.push-notifications`\n\nFor more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent)."]]