Ways to resolve the issue: "Mandatory aggregateBy parameter missing" in the fitness API

I'm struggling with an error that keeps popping up saying "Error: Require at least one aggregateby" and I have no idea how to resolve it.

I've attempted several methods:

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

Does anyone have a solution for this issue? Any assistance would be greatly appreciated!!!

Answer №1

Link to the correct solution

This is the accurate code snippet:

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

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Mongoose reverse population involves querying a document's references

I am currently exploring ways to populate my business orders using the businessId property in my orders collection. I attempted a solution but I am facing difficulties making it work. https://www.npmjs.com/package/mongoose-reverse-populate If you have an ...

Page not found: unique error on alternate route

My website has different paths and pages in hbs format, such as root, help, and 404. The problem arises when I navigate to localhost:3000/wrong, the site displays correctly, but when I try localhost:3000/help/wrong, the CSS is not applied to the 404 page b ...

Developing a REST API for a component with 18 interconnected elements

Currently, I am developing a REST API to expose a table to an Angular frontend, and I've encountered a unique challenge: The data required for display is spread across 10 different tables besides the main entity (referred to as "Ticket"). Retrieving t ...

Typescript service wrapper class returning Axios HEAD request

I am attempting to retrieve the header response using a custom Axios HTTP service wrapper. axiosClass.ts import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios"; class Http { private instance: AxiosInstance | null = n ...

Guide to uploading a JavaScript File object to Cloudinary via the node.js API

After researching various options, I decided to use cloudinary for uploading a file to an image server from my node js api. I successfully installed the npm package for cloudinary and implemented the code based on their api documentation Below is the fun ...

Issue with inserting data into MySQL database using Node.js (JavaScript)

I am attempting to utilize the insert function but keep encountering an error. I want to add a user's name to the user table. The function I am using is: function insert(tableName, toField, value){ connection.connect(); var queryString = "i ...

Is it secure to use ES6 in Typescript with nodejs/koa?

As I transition to using TypeScript in a Node.js/koa project, I came across the need to modify the .tsconfig file to target ES6. Otherwise, an error message will appear stating: Generators are only available when targeting ECMAScript 6 or higher. // index ...

New and Improved: Node.js Integration for Handling POST Requests with Rally's Latest API Authorization Version 2.0

After setting up a Node.js server to handle Rally POST requests, everything was working perfectly until I made the switch to the new Rally v2.0 API. The updated authorization model has left me scratching my head on what changes I need to make to my serve ...

How should one go about publishing an npm package developed using Browserify in the package.json file?

I have a npm package that I developed using Browserify and I'm unsure about the correct way to structure the package.json. This package is a node server-client app (specifically an atom package), with the client side built on Browseriy. ./www/js/ind ...

Ways to protect your ExpressJS RESTful API from unauthorized access

Is it possible to enhance security for an expressjs RESTful API so that only a react native app and react website have access? For example, the server runs on port 8000, the react native app is on port 3000, and the website on port 5000. It’s desired th ...

Retrieve the outcome of a mongoose query within a designated function

Seeking help with returning a result from my mongoose find operation. While similar questions have been asked before, this one is unique. Here's an example of my user: let UserSchema = new mongoose.Schema({ variable: {type: mongoose.Schema.Object ...

Setting up secure https for a node.js server in a Docker container on an AWS EC2 instance involves several steps. Let

I have a dockerized node.js/express application up and running on an AWS EC2 instance container. Currently, the app is accessible via a domain name hosted by AWS Route 53 using the HTTP protocol. I am now looking to configure HTTPS for my node.js server th ...

What is the reason behind npm's decision to categorize dependencies into two separate categories?

Within your package.json, you will find the sections for dependencies and devDependencies. { "devDependencies": { "webpack": "^4.42.1" }, "dependencies": { "react": "^16.13.1" } } The purpose behind this division is clear: dependencies ...

Encountering an error with the node module timestampnotes: 'command not recognized'

I am encountering an issue while trying to utilize a npm package called timestamp notes. After executing the following commands: $npm install timestampnotes $timestamp I receive the error message: timestamp:126: command not found: slk Subsequently, I ...

Generate a random number using the Math.random() method in Node.js/JavaScript to access a folder on the local machine

I am facing a challenge in reading a JSON file located deep within multiple folders on my local machine. The issue arises because the folder name where the file is stored changes every time, as it is generated using the Math.random() method with the prefix ...

What is the process for executing the npm pack command in my application?

Is there a way to execute the npm pack command within my node application? Would it be similar to the following code snippet? const npm = require('npm') const result = npm.pack('sourcefolder', 'targetdir'); //the result wil ...

Differences between ClosureFeedbackCellArray and FeedbackVector in the V8 engine

Can you explain the distinction between ClosureFeedbackCellArray and FeedbackVector within V8? What steps are necessary to initiate the shift from ClosureFeedbackCellArray to FeedbackVector? What is the significance of the InterruptBudget attribute found ...

The Cordova advanced HTTP POST request functionality is not functioning as expected

I'm currently in the process of connecting my backend to a cordova application, and at this early stage of development, I'm attempting to test it in the browser. Unfortunately, I'm facing an issue with the post request not working, as well a ...

Looking for regex to extract dynamic category items in node.js

Working on node.js with regex, I have accomplished the following tasks: Category 1.2 Category 1.3 and 1.4 Category 1.3 to 1.4 CATEGORY 1.3 The current regex is ((cat|Cat|CAT)(?:s\.|s|S|egory|EGORY|\.)?)( |\s)?((\w+)?([. ...

Managing incoming server events from multiple pods

Currently, I am developing a NodeJS server that has an /events endpoint for sending events to clients using SSE. In addition to this endpoint, there are multiple routes for handling POST requests. I am faced with the challenge of setting up this system so ...