Google-api-nodejs-client: Sheets 'Must specify at least one request.' error

Created on 14 Feb 2018  路  9Comments  路  Source: googleapis/google-api-nodejs-client

With the V4 API, sheets.spreadsheets.batchUpdate is responding with 'ERROR: Must specify at least one request' when used in Node.js, even when I specify a valid request body.

const options = {
  spreadsheetId: defaultConfig.spreadsheetId,
  auth: auth.authClient,
  resource: {requests: requests}
};
sheets.spreadsheets.batchUpdate(options, function (error, other){
  console.log(error);
});

Most helpful comment

Yea, nah... I just spent the past 6 hours on this one.
batchupdate is totally broke. My guess is, something to do with changes in 26.0 for es6.

Rollback to a previous working version of googleapis, version 21.3.0 works for me. 26.0.1 Gave me same error.

All 9 comments

Try a request like in the docs:
https://developers.google.com/sheets/api/guides/batchupdate

Your requests object is probably wrong, or the version of the library the command is using is broken.

Yea, nah... I just spent the past 6 hours on this one.
batchupdate is totally broke. My guess is, something to do with changes in 26.0 for es6.

Rollback to a previous working version of googleapis, version 21.3.0 works for me. 26.0.1 Gave me same error.

@grant I promise you it's not incorrect, even the examples on Google's site fail

@jetrii Can you provide a full request and provide specific versions of the libraries? The latest version is probably broken.

In the meantime, use v25 instead of v26.

@grant I was on 26.0.1, but V25 doesn't work either. I reverted back to version 21.3.0 as suggested by @smurftruesmart and it worked. As for the specific examples, literally all batchUpdate requests fail, but started working after reverting to 21.x. I'll post specific examples tomorrow if needed.

I'm following the tutorial on Using Google Sheets as your application reporting tool
https://codelabs.developers.google.com/codelabs/sheets-api/#0
When I get to Step 8 - Add Header Row
https://codelabs.developers.google.com/codelabs/sheets-api/#7

Which adds batchupdate to the sheets.js as the following code:
var dataSheetId = spreadsheet.sheets[0].properties.sheetId; var requests = [ buildHeaderRowRequest(dataSheetId), ]; // TODO: Add pivot table and chart. var request = { spreadsheetId: spreadsheet.spreadsheetId, resource: { requests: requests } }; self.service.spreadsheets.batchUpdate(request, function(err, response) { if (err) { return callback(err); } return callback(null, spreadsheet); });

Now I get error:
{"message":"Must specify at least one request.","error":{"code":400,"errors":[{"message":"Must specify at least one request.","domain":"global","reason":"badRequest"}]}}

"dependencies": {
"body-parser": "~1.13.2",
"express": "^4.13.4",
"express-handlebars": "^3.0.0",
"google-auth-library": "^0.12.0",
"googleapis": "^25.0.0",
"morgan": "^1.7.0",
"sequelize": "^3.21.0",
"sqlite3": "^3.1.3"
},

The issue is that version 25+ of this library requires google-auth-library 1.0+, since it uses the HTTP transport defined there. I've fixed the codelab so that it targets compatible versions.

Sounds like we have an answer here :) Indeed, you should NOT directly install google-auth-library, since googleapis comes with a compatible client built-in. Thanks for the fix @erickoledadevrel!

@jetrii please do let us know if you're still having issues after removing google-auth-library from your package.json.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

peterpme picture peterpme  路  3Comments

JustinBeckwith picture JustinBeckwith  路  3Comments

eduDorus picture eduDorus  路  3Comments

ACMerriman picture ACMerriman  路  3Comments

streamnsight picture streamnsight  路  4Comments