我需要同步喝水的量,在阅读了文档之后,我正在尝试请求创建一个新的数据源:
POST /fitness/v1/users/me/dataSources HTTP/1.1
Host: www.googleapis.com
Content-length: 342
Content-type: application/json
Authorization: Bearer -....-
{
"dataStreamName": "HydrationSource",
"type": "raw",
"application": {
"detailsUrl": "http://example.com",
"name": "My Example App",
"version": "1"
},
"dataType": {
"name": "com.google.hydration",
"field": [
{
"name": "volume",
"format": "floatPoint",
"optional": false
}
]
}
}
但我得到“无法修改 com.google.hydration 类型的数据”
HTTP/1.1 403 Forbidden
Content-length: 305
X-xss-protection: 0
X-content-type-options: nosniff
Transfer-encoding: chunked
Vary: Origin, X-Origin, Referer
Server: ESF
-content-encoding: gzip
Cache-control: private
Date: Tue, 12 Oct 2021 12:23:22 GMT
X-frame-options: SAMEORIGIN
Alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Content-type: application/json; charset=UTF-8
{
"error": {
"status": "PERMISSION_DENIED",
"message": "Cannot modify data of type com.google.hydration",
"code": 403,
"errors": [
{
"reason": "forbidden",
"message": "Cannot modify data of type com.google.hydration",
"domain": "global"
}
]
}
}
Fitness.nutrition.write 已启用:
我正在检查docs中的示例,因此com.google.nutrition的示例有效:
POST /fitness/v1/users/me/dataSources HTTP/1.1
Host: www.googleapis.com
Content-length: 229
Content-type: application/json
Authorization: Bearer -....-
{
"dataStreamName": "NutritionSource",
"type": "raw",
"application": {
"detailsUrl": "http://example.com",
"name": "My Example App",
"version": "1"
},
"dataType": {
"name": "com.google.nutrition",
}
}
HTTP/1.1 200 OK
Content-length: 622
X-xss-protection: 0
X-content-type-options: nosniff
Transfer-encoding: chunked
Vary: Origin, X-Origin, Referer
Server: ESF
-content-encoding: gzip
Cache-control: private
Date: Tue, 12 Oct 2021 12:21:36 GMT
X-frame-options: SAMEORIGIN
Alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Content-type: application/json; charset=UTF-8
{
"dataQualityStandard": [],
"dataType": {
"field": [
{
"name": "nutrients",
"format": "map"
},
{
"optional": true,
"name": "meal_type",
"format": "integer"
},
{
"optional": true,
"name": "food_item",
"format": "string"
}
],
"name": "com.google.nutrition"
},
"dataStreamName": "NutritionSource",
"application": {
"version": "1",
"name": "My Example App",
"detailsUrl": "http://example.com"
},
"dataStreamId": "raw:com.google.nutrition:407408718192:NutritionSource",
"type": "raw"
}
但是com.google.hydration不起作用,即使它们来自相同的权限