gpt4 book ai didi

json - Google fit API 根据范围添加多种数据类型

转载 作者:行者123 更新时间:2023-12-03 19:09:11 25 4
gpt4 key购买 nike

我正在使用具有多个用户范围的 google fit API。如何为每个源添加多种数据类型。如果可能,为什么我不能将其添加为数据源。

{
"dataStreamName":"MyDataSource",
"type":"derived",
"application":{
"detailsUrl":"http://example.com",
"name":"Foo Example App",
"version":"1"
},
"dataType":[
{
//1st data type
"name":"com.google.step_count.delta",
"field":[
{
"name":"steps",
"format":"int"
}
]
},
{
//2nd data type
"name":"com.google.calories.bmr",
"field":[
{
"name":"calories",
"format":"float"
}
]
}
],
"device":{
"manufacturer":"Example Manufacturer",
"model":"ExampleTablet",
"type":"tablet",
"uid":"1000001",
"version":"1.0"
}
}
我得到了回应
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"dataType\" at 'data_source': Proto field is not repeating, cannot start list.",
"errors": [
{
"message": "Invalid JSON payload received. Unknown name \"dataType\" at 'data_source': Proto field is not repeating, cannot start list.",
"reason": "invalid"
}
],
"status": "INVALID_ARGUMENT"
}
}
但是当我只添加一个这样的范围时
{
"dataStreamName":"MyDataSource",
"type":"derived",
"application":{
"detailsUrl":"http://example.com",
"name":"Foo Example App",
"version":"1"
},
"dataType":{
"name":"com.google.step_count.delta",
"field":[
{
"name":"steps",
"format":"integer"
}
]
},
"device":{
"manufacturer":"Example Manufacturer",
"model":"ExampleTablet",
"type":"tablet",
"uid":"1000001",
"version":"1.0"
}
}
它返回我 200,这是成功的。我错过了什么还是我正在努力做的可能?谢谢。
Google Fit API 引用
https://developers.google.com/fit/rest/v1/reference/users/dataSources/create

最佳答案

我相信您尝试做的嵌套必须在 dataField 级别而不是 dataType 级别进行。
数据类型.field[]
我认为这是因为我注意到 'field[]' 是一个集合,而 dataType 不是。

关于json - Google fit API 根据范围添加多种数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62775283/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com