问题
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