我不断收到这些错误“错误:至少需要一个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 }
}
)};
有人知道如何解决它吗?任何帮助将不胜感激!!!
答案 0 :(得分: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);
}
);