How to fix Error: Require at least one aggregateby? - fitness api

佐手、 提交于 2020-04-17 22:53:48

问题


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

I have tried many ways:

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

and:

        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!!!


回答1:


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

this is correct:

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


来源:https://stackoverflow.com/questions/57689170/how-to-fix-error-require-at-least-one-aggregateby-fitness-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!