Users.dataSources.datasets: patch
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.
Thêm các điểm dữ liệu vào một tập dữ liệu. Tập dữ liệu không cần được tạo trước đó.
Tất cả điểm trong tập dữ liệu nhất định sẽ được trả về cùng với các lệnh gọi tương ứng
để truy xuất tập dữ liệu này. Các điểm dữ liệu có thể thuộc về nhiều tập dữ liệu.
Phương thức này không sử dụng ngữ nghĩa của bản vá: các điểm dữ liệu được cung cấp là
chỉ được chèn mà không có dữ liệu hiện có nào bị thay thế.
Thử ngay.
Yêu cầu
Yêu cầu HTTP
PATCH https://www.googleapis.com/fitness/v1/users/userId/dataSources/dataSourceId/datasets/datasetId
Tham số
Tên thông số |
Giá trị |
Mô tả |
Tham số đường dẫn |
dataSourceId |
string |
Mã luồng dữ liệu của nguồn dữ liệu đã tạo tập dữ liệu.
|
datasetId |
string |
Trường này không được sử dụng và bạn có thể bỏ qua một cách an toàn.
|
userId |
string |
Vá một tập dữ liệu cho người được xác định. Sử dụng me để cho biết
người dùng đã xác thực. Hiện chỉ hỗ trợ me .
|
Ủy quyền
Yêu cầu này cần có sự uỷ quyền với ít nhất một trong các phạm vi sau:
Phạm vi |
https://www.googleapis.com/auth/fitness.activity.write |
https://www.googleapis.com/auth/fitness.location.write |
https://www.googleapis.com/auth/fitness.body.write |
https://www.googleapis.com/auth/fitness.nutrition.write |
https://www.googleapis.com/auth/fitness.blood_pressure.write |
https://www.googleapis.com/auth/fitness.blood_glucose.write |
https://www.googleapis.com/auth/fitness.oxygen_saturation.write |
https://www.googleapis.com/auth/fitness.body_temperature.write |
https://www.googleapis.com/auth/fitness.reproductive_health.write |
Để biết thêm thông tin, hãy xem trang xác thực và uỷ quyền.
Nội dung yêu cầu
Trong nội dung yêu cầu, hãy cung cấp các phần có liên quan của tài nguyên Users.dataSources.datasets theo quy tắc về ngữ nghĩa của bản vá với các thuộc tính sau:
Tên tài sản |
Giá trị |
Mô tả |
Ghi chú |
Thuộc tính bắt buộc |
dataSourceId |
string |
Mã luồng dữ liệu của nguồn dữ liệu đã tạo điểm trong tập dữ liệu này. |
|
maxEndTimeNs |
long |
Thời gian kết thúc lớn nhất của tất cả điểm dữ liệu trong bản trình bày một phần của tập dữ liệu này. Thời gian tính bằng nano giây kể từ thời gian bắt đầu của hệ thống. Mã này cũng phải khớp với phần thứ hai của giá trị nhận dạng tập dữ liệu. |
|
minStartTimeNs |
long |
Thời gian bắt đầu nhỏ nhất của tất cả các điểm dữ liệu trong cách biểu diễn một phần tập dữ liệu này có thể là. Thời gian tính bằng nano giây kể từ thời gian bắt đầu của hệ thống. Mã này cũng phải khớp với phần đầu tiên của giá trị nhận dạng tập dữ liệu. |
|
point[] |
list |
Danh sách một phần các điểm dữ liệu có trong tập dữ liệu, được sắp xếp theo endTimeNanos. Danh sách này được coi là hoàn chỉnh khi truy xuất một tập dữ liệu nhỏ và truy xuất một phần tập dữ liệu trong trường hợp vá một tập dữ liệu hoặc truy xuất một tập dữ liệu quá lớn để đưa vào một phản hồi. |
|
point[].dataTypeName |
string |
Loại dữ liệu xác định định dạng của các giá trị trong điểm dữ liệu này. |
|
point[].endTimeNanos |
long |
Thời gian kết thúc của khoảng thời gian được biểu thị bằng điểm dữ liệu này, tính bằng nano giây kể từ thời gian bắt đầu của hệ thống. |
|
point[].startTimeNanos |
long |
Thời gian bắt đầu của khoảng thời gian được biểu thị bằng điểm dữ liệu này, tính bằng nano giây kể từ thời gian bắt đầu của hệ thống. |
|
point[].value[] |
list |
Giá trị của mỗi trường loại dữ liệu cho điểm dữ liệu. Theo dự kiến, mỗi giá trị tương ứng với một trường loại dữ liệu sẽ xuất hiện theo cùng thứ tự mà trường được liệt kê trong loại dữ liệu được chỉ định trong nguồn dữ liệu.
Chỉ một trong các trường số nguyên và dấu phẩy động sẽ được điền sẵn, tuỳ thuộc vào giá trị enum của định dạng trong trường loại của nguồn dữ liệu.
|
|
Hãy dùng thử!
Hãy sử dụng APIs Explorer (Trình khám phá API) bên dưới để gọi phương thức này trên dữ liệu trực tiếp và xem phản hồi.
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."],[[["\u003cp\u003eAdds data points to a new or existing dataset within Google Fit, returning all dataset points upon retrieval.\u003c/p\u003e\n"],["\u003cp\u003eUtilizes an insert-only approach, without replacing pre-existing data.\u003c/p\u003e\n"],["\u003cp\u003eRequires authorization with specific scopes, such as \u003ccode\u003ehttps://www.googleapis.com/auth/fitness.activity.write\u003c/code\u003e, for data access.\u003c/p\u003e\n"],["\u003cp\u003eThe request body necessitates properties like \u003ccode\u003edataSourceId\u003c/code\u003e, \u003ccode\u003emaxEndTimeNs\u003c/code\u003e, \u003ccode\u003eminStartTimeNs\u003c/code\u003e, and an array of data points (\u003ccode\u003epoint[]\u003c/code\u003e) with corresponding values.\u003c/p\u003e\n"],["\u003cp\u003eSuccessful requests return a \u003ccode\u003eUsers.dataSources.datasets\u003c/code\u003e resource containing the updated dataset information.\u003c/p\u003e\n"]]],[],null,["# Users.dataSources.datasets: patch\n\n| **Note:** Requires [authorization](#auth).\n\nAdds data points to a dataset. The dataset need not be previously created.\nAll points within the given dataset will be returned with subsquent calls\nto retrieve this dataset. Data points can belong to more than one dataset.\n\n\u003cbr /\u003e\n\n\nThis method does not use patch semantics: the data points provided are\nmerely inserted, with no existing data replaced.\n[Try it now](#try-it).\n\nRequest\n-------\n\n### HTTP request\n\n```\nPATCH https://www.googleapis.com/fitness/v1/users/userId/dataSources/dataSourceId/datasets/datasetId\n```\n\n### Parameters\n\n| Parameter name | Value | Description |\n|----------------|----------|------------------------------------------------------------------------------------------------------------------------------|\n| **Path parameters** |||\n| `dataSourceId` | `string` | The data stream ID of the data source that created the dataset. |\n| `datasetId` | `string` | This field is not used, and can be safely omitted. |\n| `userId` | `string` | Patch a dataset for the person identified. Use `me` to indicate the authenticated user. Only `me` is supported at this time. |\n\n### Authorization\n\nThis request requires authorization with at least one of the following scopes:\n\n| Scope |\n|---------------------------------------------------------------------|\n| `https://www.googleapis.com/auth/fitness.activity.write` |\n| `https://www.googleapis.com/auth/fitness.location.write` |\n| `https://www.googleapis.com/auth/fitness.body.write` |\n| `https://www.googleapis.com/auth/fitness.nutrition.write` |\n| `https://www.googleapis.com/auth/fitness.blood_pressure.write` |\n| `https://www.googleapis.com/auth/fitness.blood_glucose.write` |\n| `https://www.googleapis.com/auth/fitness.oxygen_saturation.write` |\n| `https://www.googleapis.com/auth/fitness.body_temperature.write` |\n| `https://www.googleapis.com/auth/fitness.reproductive_health.write` |\n\nFor more information, see the [authentication and authorization](/fit/rest/v1/authorization) page.\n\n### Request body\n\nIn the request body, supply the relevant portions of a [Users.dataSources.datasets resource](/fit/rest/v1/reference/users/dataSources/datasets#resource), according to the rules of patch semantics, with the following properties:\n\n| Property name | Value | Description | Notes |\n|--------------------------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------|\n| **Required Properties** ||||\n| `dataSourceId` | `string` | The data stream ID of the data source that created the points in this dataset. | |\n| `maxEndTimeNs` | `long` | The largest end time of all data points in this possibly partial representation of the dataset. Time is in nanoseconds from epoch. This should also match the second part of the dataset identifier. | |\n| `minStartTimeNs` | `long` | The smallest start time of all data points in this possibly partial representation of the dataset. Time is in nanoseconds from epoch. This should also match the first part of the dataset identifier. | |\n| `point[]` | `list` | A partial list of data points contained in the dataset, ordered by endTimeNanos. This list is considered complete when retrieving a small dataset and partial when patching a dataset or retrieving a dataset that is too large to include in a single response. | |\n| point[].`dataTypeName` | `string` | The data type defining the format of the values in this data point. | |\n| point[].`endTimeNanos` | `long` | The end time of the interval represented by this data point, in nanoseconds since epoch. | |\n| point[].`startTimeNanos` | `long` | The start time of the interval represented by this data point, in nanoseconds since epoch. | |\n| point[].`value[]` | `list` | Values of each data type field for the data point. It is expected that each value corresponding to a data type field will occur in the same order that the field is listed with in the data type specified in a data source. Only one of integer and floating point fields will be populated, depending on the format enum value within data source's type field. | |\n\nResponse\n--------\n\nIf successful, this method returns a [Users.dataSources.datasets resource](/fit/rest/v1/reference/users/dataSources/datasets#resource) in the response body.\n\nTry it!\n-------\n\n\nUse the APIs Explorer below to call this method on live data and see the response."]]