如何解决错误:至少需要一个aggregateby? -健身api

问题描述 投票:0回答:1

我一直收到这些错误“错误:至少需要一个aggregateby”,却不知道如何解决。

我尝试了很多方法:

        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 }
                }
    )};

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

node.js rest google-api google-fit
1个回答
0
投票

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);
    }
  );
© www.soinside.com 2019 - 2024. All rights reserved.