GroupItems: insert
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.
Yêu cầu
Yêu cầu HTTP
POST https://youtubeanalytics.googleapis.com/v2/groupItems
Ủy quyền
Yêu cầu này yêu cầu uỷ quyền với ít nhất một trong các phạm vi sau (đọc thêm về việc xác thực và uỷ quyền).
Phạm vi |
https://www.googleapis.com/auth/yt-analytics.readonly |
Xem báo cáo YouTube Analytics cho nội dung trên YouTube của bạn. Phạm vi này cung cấp quyền truy cập vào các chỉ số về hoạt động của người dùng, chẳng hạn như số lượt xem và số lượt xếp hạng. |
https://www.googleapis.com/auth/yt-analytics-monetary.readonly |
Xem các báo cáo tài chính của YouTube Analytics cho nội dung trên YouTube của bạn. Phạm vi này cung cấp quyền truy cập vào các chỉ số về hoạt động của người dùng, cũng như các chỉ số về doanh thu ước tính và hiệu suất quảng cáo. |
https://www.googleapis.com/auth/youtube |
Quản lý tài khoản YouTube của bạn. Trong API YouTube Analytics, chủ sở hữu kênh sử dụng phạm vi này để quản lý các nhóm và mục trong nhóm trên YouTube Analytics. |
https://www.googleapis.com/auth/youtubepartner |
Xem và quản lý tài sản cũng như nội dung được liên kết trên YouTube. Trong API YouTube Analytics, chủ sở hữu nội dung sử dụng phạm vi này để quản lý các nhóm và mục trong nhóm trên YouTube Analytics. |
Thông số
Bảng dưới đây liệt kê các tham số mà truy vấn này hỗ trợ. Tất cả các tham số được liệt kê đều là tham số truy vấn.
Thông số |
Tham số không bắt buộc |
onBehalfOfContentOwner |
string
Bạn chỉ có thể sử dụng thông số này trong một yêu cầu được uỷ quyền hợp lệ. Lưu ý: Thông số này chỉ dành cho những đối tác nội dung trên YouTube sở hữu và quản lý nhiều kênh YouTube.
Thông số onBehalfOfContentOwner cho biết rằng thông tin xác thực uỷ quyền của yêu cầu xác định một người dùng YouTube đang thay mặt cho chủ sở hữu nội dung được chỉ định trong giá trị thông số. Tính năng này cho phép chủ sở hữu nội dung xác thực một lần và có quyền truy cập vào tất cả dữ liệu về video và kênh của họ mà không cần phải cung cấp thông tin xác thực cho từng kênh. Tài khoản mà người dùng xác thực phải được liên kết với chủ sở hữu nội dung YouTube được chỉ định. |
Nội dung yêu cầu
Cung cấp tài nguyên groupItem trong phần nội dung yêu cầu.
Đối với tài nguyên đó, bạn phải chỉ định giá trị cho các thuộc tính sau.
Phản hồi
Nếu chèn thành công mục, phương thức này sẽ trả về một tài nguyên groupItem trong phần nội dung phản hồi.
Nếu mục được chỉ định trong yêu cầu đã có trong nhóm trước khi yêu cầu được thực hiện, thì phương thức này sẽ trả về mã phản hồi 204
HTTP (No Content
).
Lỗi
Bảng dưới đây xác định thông báo lỗi mà API có thể trả về để phản hồi lệnh gọi đến phương thức này. Vui lòng xem tài liệu về thông báo lỗi để biết thêm thông tin chi tiết.
Loại lỗi |
Chi tiết về lỗi |
Mô tả |
forbidden (403) |
groupContainsMaximumNumberOfItems |
Nhóm này đã chứa số mục tối đa được phép. |
Hãy dùng thử!
Sử dụng APIs Explorer để gọi API này và xem yêu cầu và phản hồi API.
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-08-21 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-21 UTC."],[[["\u003cp\u003eThis API endpoint allows you to create a new group item within YouTube Analytics.\u003c/p\u003e\n"],["\u003cp\u003eAuthorization is required using specific scopes, including options for both content owners and channel owners.\u003c/p\u003e\n"],["\u003cp\u003eThe request must include a groupItem resource in the body, specifying the \u003ccode\u003egroupId\u003c/code\u003e and \u003ccode\u003eresource.id\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eA successful insertion of the item returns a groupItem resource, and attempting to add a pre-existing item returns a \u003ccode\u003e204\u003c/code\u003e HTTP code.\u003c/p\u003e\n"],["\u003cp\u003eThe API will return a \u003ccode\u003e403\u003c/code\u003e error if the group has reached its maximum item capacity.\u003c/p\u003e\n"]]],["This documentation details the process of creating a group item via a `POST` request to the YouTube Analytics API (`/groupItems`). Authorization requires specific scopes, including `yt-analytics.readonly`, `yt-analytics-monetary.readonly`, `youtube`, or `youtubepartner`. The request body must include a `groupItem` resource, specifying `groupId` and `resource.id`. Content owners can use `onBehalfOfContentOwner` to authenticate for multiple channels. Successful creation returns the `groupItem` resource; a duplicate returns a `204` status. A `403` error occurs when the maximum number of items is reached.\n"],null,["# GroupItems: insert\n\nCreates a group item.\n\nRequest\n-------\n\n### HTTP request\n\n```\nPOST https://youtubeanalytics.googleapis.com/v2/groupItems\n```\n\n### Authorization\n\nThis request requires authorization with at least one of the following scopes ([read more about authentication and authorization](/youtube/analytics/authentication)).\n\n| Scopes ||\n|----------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| https://www.googleapis.com/auth/yt-analytics.readonly | View YouTube Analytics reports for your YouTube content. This scope provides access to user activity metrics, like view counts and rating counts. |\n| https://www.googleapis.com/auth/yt-analytics-monetary.readonly | View YouTube Analytics monetary reports for your YouTube content. This scope provides access to user activity metrics and to estimated revenue and ad performance metrics. |\n| https://www.googleapis.com/auth/youtube | Manage your YouTube account. In the YouTube Analytics API, channel owners use this scope to manage YouTube Analytics groups and group items. |\n| https://www.googleapis.com/auth/youtubepartner | View and manage YouTube assets and associated content on YouTube. In the YouTube Analytics API, content owners use this scope to manage YouTube Analytics groups and group items. |\n\n### Parameters\n\nThe table below lists the parameters that this query supports. All of the parameters listed are query parameters.\n\n| Parameters ||\n|--------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| **Optional parameters** |||\n| `onBehalfOfContentOwner` | `string` This parameter can only be used in a properly [authorized request](/youtube/analytics/authentication). **Note:** This parameter is intended exclusively for YouTube content partners that own and manage many different YouTube channels. The **onBehalfOfContentOwner** parameter indicates that the request's authorization credentials identify a YouTube user who is acting on behalf of the content owner specified in the parameter value. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The account that the user authenticates with must be linked to the specified YouTube content owner. |\n\n### Request body\n\nProvide a [groupItem resource](/youtube/analytics/reference/groupItems#resource) in the request body.\nFor that resource, you must specify a value for the following properties.\n\n\u003cbr /\u003e\n\n- `groupId`\n- `resource.id`\n\n\u003cbr /\u003e\n\nResponse\n--------\n\nIf the item is successfully inserted, this method returns a [groupItem resource](/youtube/analytics/reference/groupItems#resource) in the response body.\n\nIf the item specified in the request had already been included in the group before the request was made, this method returns an HTTP `204` response code (`No Content`).\n\nErrors\n------\n\nThe table below identifies error messages that the API could return in response to a call to this method. Please see the [error message](/youtube/analytics/reference/errors) documentation for more detail.\n\n| Error type | Error detail | Description |\n|-------------------|-------------------------------------|-----------------------------------------------------------------|\n| `forbidden (403)` | `groupContainsMaximumNumberOfItems` | The group already contains the maximum allowed number of items. |\n\nTry it!\n-------\n\nUse the APIs Explorer to call this API and see the API request and response."]]