Users.dataSources.datasets: patch
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เพิ่มจุดข้อมูลลงในชุดข้อมูล ไม่จำเป็นต้องสร้างชุดข้อมูลก่อนหน้านี้
จุดทั้งหมดภายในชุดข้อมูลที่ระบุจะได้รับการส่งคืนพร้อมกับการเรียกใช้ครั้งต่อๆ ไป
เพื่อดึงข้อมูลชุดข้อมูลนี้ จุดข้อมูลสามารถอยู่ในชุดข้อมูลได้มากกว่า 1 รายการ
วิธีนี้ไม่ได้ใช้ความหมายของแพตช์: จุดข้อมูลที่ระบุคือ
แทรกไว้เท่านั้น โดยไม่มีข้อมูลใดมาแทนที่
ลองใช้เลย
ส่งคำขอ
คำขอ HTTP
PATCH https://www.googleapis.com/fitness/v1/users/userId/dataSources/dataSourceId/datasets/datasetId
พารามิเตอร์
ชื่อพารามิเตอร์ |
ค่า |
คำอธิบาย |
พารามิเตอร์เส้นทาง |
dataSourceId |
string |
รหัสสตรีมข้อมูลของแหล่งข้อมูลที่สร้างชุดข้อมูล
|
datasetId |
string |
ไม่ได้ใช้ฟิลด์นี้ และสามารถละเว้นได้อย่างปลอดภัย
|
userId |
string |
แพตช์ชุดข้อมูลของบุคคลที่ระบุ ใช้ me เพื่อระบุ
ผู้ใช้ที่ตรวจสอบสิทธิ์แล้ว รองรับ me เท่านั้นในขณะนี้
|
การให้สิทธิ์
คำขอนี้ต้องได้รับการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 ขอบเขต
ขอบเขต |
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 |
สำหรับข้อมูลเพิ่มเติม โปรดดูที่หน้าการตรวจสอบสิทธิ์และการให้สิทธิ์
เนื้อหาของคำขอ
ในเนื้อหาคำขอ ให้ระบุส่วนที่เกี่ยวข้องของทรัพยากร Users.dataSources.datasets ตามกฎของแพตช์เชิงอรรถด้วยพร็อพเพอร์ตี้ต่อไปนี้
ชื่อพร็อพเพอร์ตี้ |
ค่า |
คำอธิบาย |
หมายเหตุ |
พร็อพเพอร์ตี้ที่จำเป็น |
dataSourceId |
string |
รหัสสตรีมข้อมูลของแหล่งข้อมูลที่สร้างจุดในชุดข้อมูลนี้ |
|
maxEndTimeNs |
long |
เวลาสิ้นสุดที่ใหญ่ที่สุดของจุดข้อมูลทั้งหมดในชุดข้อมูลนี้ซึ่งอาจนำเสนอเพียงบางส่วน เวลานับจาก Epoch ในหน่วยนาโนวินาที ซึ่งควรตรงกับส่วนที่ 2 ของตัวระบุชุดข้อมูลด้วย |
|
minStartTimeNs |
long |
เวลาเริ่มต้นที่น้อยที่สุดของจุดข้อมูลทั้งหมดในชุดข้อมูลนี้ซึ่งอาจนำเสนอเพียงบางส่วน เวลานับจาก Epoch ในหน่วยนาโนวินาที ซึ่งควรตรงกับส่วนแรกของตัวระบุชุดข้อมูลด้วย |
|
point[] |
list |
รายการจุดข้อมูลบางส่วนที่อยู่ในชุดข้อมูล เรียงลำดับตาม endTimeNanos รายการนี้จะถือว่าเสร็จสมบูรณ์เมื่อดึงชุดข้อมูลขนาดเล็กและบางส่วนเมื่อแพตช์ชุดข้อมูลหรือดึงข้อมูลชุดข้อมูลที่มีขนาดใหญ่เกินไปที่จะรวมไว้ในการตอบกลับเดียว |
|
point[].dataTypeName |
string |
ประเภทข้อมูลที่กำหนดรูปแบบของค่าในจุดข้อมูลนี้ |
|
point[].endTimeNanos |
long |
เวลาสิ้นสุดของช่วงเวลาที่จุดข้อมูลนี้แสดง ในหน่วยนาโนวินาทีนับตั้งแต่ Epoch |
|
point[].startTimeNanos |
long |
เวลาเริ่มต้นของช่วงเวลาที่จุดข้อมูลนี้แสดง ในหน่วยนาโนวินาทีนับตั้งแต่ Epoch |
|
point[].value[] |
list |
ค่าของช่องประเภทข้อมูลแต่ละประเภทสำหรับจุดข้อมูล คาดว่าแต่ละค่าที่เกี่ยวข้องกับช่องประเภทข้อมูลจะเกิดขึ้นในลำดับเดียวกันกับที่ช่องแสดงในประเภทข้อมูลที่ระบุไว้ในแหล่งข้อมูล
ระบบจะป้อนข้อมูลในช่องจำนวนเต็มและจุดทศนิยมเพียง 1 ช่องเท่านั้น โดยขึ้นอยู่กับค่า Enum ของรูปแบบภายในช่องประเภทของแหล่งข้อมูล
|
|
ลองใช้งาน
ใช้ API Explorer ด้านล่างเพื่อเรียกใช้เมธอดนี้กับข้อมูลแบบสดและดูการตอบกลับ
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 UTC
[null,null,["อัปเดตล่าสุด 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."]]