Google适合REST API无法添加部分数据源

Google fit REST API Cannot add some of the data source

我正在尝试添加一个特定的数据源,范围是

https://www.googleapis.com/auth/fitness.activity.read
https://www.googleapis.com/auth/fitness.activity.write

但是当我尝试这样做时。它 returns 我的错误

      {
        "reason": "invalidArgument", 
        "message": "Data type does not match well-known data type with the same name", 
        "domain": "global"
      }

我向这个URL发送POST请求 https://www.googleapis.com/fitness/v1/users/me/dataSources

这是我的请求正文

{
  "dataStreamName": "MyDataSource",
  "type": "derived",
  "application": {
    "detailsUrl": "http://example.com",
    "name": "Foo Example App",
    "version": "1"
  },
  "dataType": {
    "field": [
      {
        "name": "activty_type",
        "format": "integer"
      }
    ],
    "name": "com.google.activity.segment"
  },
  "device": {
    "manufacturer": "Example Manufacturer",
    "model": "ExampleTablet",
    "type": "tablet",
    "uid": "1000001",
    "version": "1.0"
  }
}

我使用 PHP/Laravel 作为一种语言,我使用 CURL 作为 http 请求库。有人可以告诉我我做错了什么吗?部分范围已成功添加,但还有一些范围无法添加。

Google 文档参考:https://developers.google.com/fit/datatypes/activity?authuser=3

根据文档,activity_type(您输入有误)不是正确的字符串。 com.google.activity.segment 需要 activity 字段。

documentation

所以这会,因为它 returns 在 Google Fit API 测试控制台中预期资源和 HTTP 200,工作:

{
  "dataStreamName": "MyDataSource",
  "type": "derived",
  "application": {
    "detailsUrl": "http://example.com",
    "name": "Foo Example App",
    "version": "1"
  },
  "dataType": {
    "field": [
      {
        "name": "activity",
        "format": "integer"
      }
    ],
    "name": "com.google.activity.segment"
  },
  "device": {
    "manufacturer": "Example Manufacturer",
    "model": "ExampleTablet",
    "type": "tablet",
    "uid": "1000001",
    "version": "1.0"
  }
}