Google-api-nodejs-client: Invalid JSON payload received. Unknown name "requests": Cannot find field.

Created on 7 Oct 2018  路  1Comment  路  Source: googleapis/google-api-nodejs-client

Environment details

  • OS: macOS 10.14
  • Node.js version: 10.2.1
  • npm version: 5.6.0
  • googleapis version: 34.0.0

Steps to reproduce

I tried to follow this example to use the batchUpdate API but I'm not able to use the API successfully.

const {google} = require('googleapis');
const sheets = google.sheets('v4');
try {
  const options = {
    auth: new google.auth.JWT(
      'client_email',
      null,
      'private_key',
      ['https://www.googleapis.com/auth/spreadsheets']
    );
    spreadsheetId: 'spreadsheetId',
    resource: {
      requests: [{
        addSheet: {properties: {title: 'title'}}
      }]
    }
  };
  await new Promise((resolve, reject) => {
    sheets.spreadsheets.values.batchUpdate(options, (err, res) => err ? reject(err) : resolve(res));
  });
} catch (error) {
  console.error(error);
}

Most helpful comment

Solved, I was using the wrong API.
sheets.spreadsheets.values.batchUpdate -> sheets.spreadsheets.batchUpdate

>All comments

Solved, I was using the wrong API.
sheets.spreadsheets.values.batchUpdate -> sheets.spreadsheets.batchUpdate

Was this page helpful?
0 / 5 - 0 ratings