我正在尝试将google health api与restapi结合使用。我知道android有一个可用的api,但我正试图将这种行为移植到后端。
我在oauth操场上玩;我试图得到一个聚合查询。我试过很多东西,但没有一个返回任何东西(只有得到错误),没有谷歌网站本身的例子。有人有这个api的经验吗?
我在stackoverflow上找到了一些例子,但是没有一个能够作为例子的解决方案或完整的查询。
HereHere
如果我能得到一个有效的聚合示例,我将从那里开始工作。
以下是我对https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate的请求:

    {
  "startTimeMillis": 1451647796000,
  "endTimeMillis": 1458127796000,
  "aggregateBy": [
    {
      "dataTypeName": "com.google.height"
    }
  ],"bucketByTime": {
    "period": {
      "type": "day",
      "value": 1,
      "timeZoneId": "org.joda.timezone.DateTimeZone"
    }
  }
}

回应:
{
  "error": {
    "code": 400,
    "message": "Bad Request",
    "errors": [
      {
        "domain": "global",
        "message": "Bad Request",
        "reason": "invalidArgument"
      }
    ]
  }
}

最佳答案

您忘记了“bucketbytime”上的“durationmillis”字段和“aggregateby”上的“datasourceid”。
时区语法类似于“america/los廑anges”,而不是“org.joda.timezone.datetimezone”。您可以在http://joda-time.sourceforge.net/timezones.html上看到这些字符串

08-25 23:21
查看更多