如何修复错误:至少需要一个aggregateby? -健身API [英] How to fix Error: Require at least one aggregateby? - fitness api

查看:83
本文介绍了如何修复错误:至少需要一个aggregateby? -健身API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不断收到这些错误错误:至少需要一个aggregateby",却不知道如何解决.

I keep getting these error "Error: Require at least one aggregateby" and no idea how to fix it.

我尝试了很多方法:

        fitness.users.dataset.aggregate({
                auth: serviceAccountAuth,
                userId: "me",
                //fields: "bucket/dataset/point/value/intVal",
                requestBody: {
                  "aggregateBy": [{
                    "dataTypeName": "com.google.step_count.delta",
                    "dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps"
                  }],
                  "endTimeMillis": 1566733471706,
                  "startTimeMillis": 1566647071706,
                  "bucketByTime": { "durationMillis": 86400000 }
                }
    )};

和:

        fitness.users.dataset.aggregate({
                auth: serviceAccountAuth,
                userId: "me",
                //fields: "bucket/dataset/point/value/intVal",
                requestBody: {
                  aggregateBy: [{
                    dataTypeName: "com.google.step_count.delta",
                    dataSourceId: "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps"
                  }],
                  endTimeMillis: 1566733471706,
                  startTimeMillis: 1566647071706,
                  bucketByTime: { durationMillis: 86400000 }
                }
    )};

有人知道如何解决它吗?任何帮助将不胜感激!!!

Anyone know how to fix it ? Any help will be really appreciated!!!

推荐答案

https://github.com/googleapis/google-api-nodejs-client/issues/1749

这是正确的:

fitness.users.dataset.aggregate(
    {
      userId: 'me',
      resource: {
        aggregateBy: [
          {
            dataSourceId:
              'derived:com.google.step_count.delta:com.google.android.gms:estimated_steps'
          }
        ],
        bucketByTime: {
          durationMillis: 86400000
        },
        startTimeMillis: 1584891702214,
        endTimeMillis: 1584978102214
      }
    },
    (err, res, aa) => {
      if (err) return console.log('The API returned an error: ' + err);
      console.log(res.data);
      const events = res.data.items;
      resolve(events);
    }
  );

这篇关于如何修复错误:至少需要一个aggregateby? -健身API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆