无法从 Google Fit Api 获取数据

时间:2021-06-10 10:03:44

标签: api rest google-fit

我需要从我的手机应用中获取一些虚拟数据(血压测量)。 我正在 GET 到 https://www.googleapis.com/fitness/v1/users/me/dataSources

我收到了这样的回复:

{
    "dataSource": [
        {
            "dataStreamId": "derived:com.google.blood_pressure:com.google.android.gms:merged",
            "dataStreamName": "merged",
            "type": "derived",
            "dataType": {
                "name": "com.google.blood_pressure",
                "field": [
                    {
                        "name": "blood_pressure_systolic",
                        "format": "floatPoint"
                    },
                    {
                        "name": "blood_pressure_diastolic",
                        "format": "floatPoint"
                    },
                    {
                        "name": "body_position",
                        "format": "integer",
                        "optional": true
                    },
                    {
                        "name": "blood_pressure_measurement_location",
                        "format": "integer",
                        "optional": true
                    }
                ]
            },
            "application": {
                "packageName": "com.google.android.gms"
            },
            "dataQualityStandard": []
        },
        {
            "dataStreamId": "raw:com.google.blood_pressure:com.google.android.apps.fitness:user_input",
            "dataStreamName": "user_input",
            "type": "raw",
            "dataType": {
                "name": "com.google.blood_pressure",
                "field": [
                    {
                        "name": "blood_pressure_systolic",
                        "format": "floatPoint"
                    },
                    {
                        "name": "blood_pressure_diastolic",
                        "format": "floatPoint"
                    },
                    {
                        "name": "body_position",
                        "format": "integer",
                        "optional": true
                    },
                    {
                        "name": "blood_pressure_measurement_location",
                        "format": "integer",
                        "optional": true
                    }
                ]
            },
            "application": {
                "packageName": "com.google.android.apps.fitness"
            },
            "dataQualityStandard": []
        }
    ]
}

然后我尝试通过执行 POST 来访问数据:

https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate

具有以下负载:

{
  "aggregateBy": [{
    "dataSourceId":
      "derived:com.google.blood_pressure:com.google.android.gms:merged"
  }],
  "bucketByTime": { "durationMillis": 86400000 },
  "startTimeMillis": 1454284800000,
  "endTimeMillis": 1455062400000
}

我收到以下回复:

{
    "bucket": [
        {
            "startTimeMillis": "1454284800000",
            "endTimeMillis": "1454371200000",
            "dataset": [
                {
                    "dataSourceId": "derived:com.google.blood_pressure.summary:com.google.android.gms:aggregated",
                    "point": []
                }
            ]
        },
        {
            "startTimeMillis": "1454371200000",
            "endTimeMillis": "1454457600000",
            "dataset": [
                {
                    "dataSourceId": "derived:com.google.blood_pressure.summary:com.google.android.gms:aggregated",
                    "point": []
                }
            ]
        },
        {
            "startTimeMillis": "1454457600000",
            "endTimeMillis": "1454544000000",
            "dataset": [
                {
                    "dataSourceId": "derived:com.google.blood_pressure.summary:com.google.android.gms:aggregated",
                    "point": []
                }
            ]
        },
        {
            "startTimeMillis": "1454544000000",
            "endTimeMillis": "1454630400000",
            "dataset": [
                {
                    "dataSourceId": "derived:com.google.blood_pressure.summary:com.google.android.gms:aggregated",
                    "point": []
                }
            ]
        },
        {
            "startTimeMillis": "1454630400000",
            "endTimeMillis": "1454716800000",
            "dataset": [
                {
                    "dataSourceId": "derived:com.google.blood_pressure.summary:com.google.android.gms:aggregated",
                    "point": []
                }
            ]
        },
        {
            "startTimeMillis": "1454716800000",
            "endTimeMillis": "1454803200000",
            "dataset": [
                {
                    "dataSourceId": "derived:com.google.blood_pressure.summary:com.google.android.gms:aggregated",
                    "point": []
                }
            ]
        },
        {
            "startTimeMillis": "1454803200000",
            "endTimeMillis": "1454889600000",
            "dataset": [
                {
                    "dataSourceId": "derived:com.google.blood_pressure.summary:com.google.android.gms:aggregated",
                    "point": []
                }
            ]
        },
        {
            "startTimeMillis": "1454889600000",
            "endTimeMillis": "1454976000000",
            "dataset": [
                {
                    "dataSourceId": "derived:com.google.blood_pressure.summary:com.google.android.gms:aggregated",
                    "point": []
                }
            ]
        },
        {
            "startTimeMillis": "1454976000000",
            "endTimeMillis": "1455062400000",
            "dataset": [
                {
                    "dataSourceId": "derived:com.google.blood_pressure.summary:com.google.android.gms:aggregated",
                    "point": []
                }
            ]
        }
    ]
}

没有返回数据

0 个答案:

没有答案
相关问题