question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Google sheet API v4 - batchUpdate provide error : Invalid JSON. Unknown name "data".

See original GitHub issue

I got an error by executing the batchUpdate function :

var options = var options = {
    auth: auth,
    spreadsheetId: spreadSheetId,
    valueInputOption: "RAW",
    data: [
        {
            range: "MyRange",
            majorDimension: majorDimension,
            values: [0,0,0,1,2,3]
        }
    ]
};

spreadsheets.batchUpdate(options, function(err, res) {
    console.log(res);
    console.log(err);
})

The error is the following :

{ [Error: Invalid JSON payload received. Unknown name "data": Cannot bind query parameter. 'data' is a message type. Parameters can only be bound to primitive types.]
  code: 400,
  errors: 
   [ { message: 'Invalid JSON payload received. Unknown name "data": Cannot bind query parameter. \'data\' is a message type. Parameters can only be bound to primitive types.',
       domain: 'global',
       reason: 'badRequest' } ] }

Im using Google sheet API v4.

‘data’ should exist in request following the documentation : https://developers.google.com/sheets/samples/writing#write_to_multiple_ranges

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

19reactions
jmdobrycommented, Aug 30, 2016

The payload of the request (not the parameters) need to be nested under a resource property:

var options = {
  auth: auth,
  spreadsheetId: spreadSheetId,
  resource: {
    valueInputOption: "RAW",
    data: [
      {
        range: "MyRange",
        majorDimension: majorDimension,
        values: [0,0,0,1,2,3]
      }
    ]
  }
};

spreadsheets.values, batchUpdate(options, function(err, res) {
    console.log(res);
    console.log(err);
});
18reactions
ehgoodenoughcommented, Jun 8, 2016

Yup, I had the same problem. Check what API call you’re making; you’re calling spreadsheets.batchUpdate instead of spreadsheets.values.batchUpdate.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google Sheets API BatchUpdate InsertRange returns "Invalid ...
I am told there is an issue both with the syntax, and earlier that the JSON names could not be found. Syntax Error:...
Read more >
Updating Spreadsheets | Google Sheets
The batchUpdate method lets you update any of these spreadsheet details. Changes are grouped together in a batch so that if one request...
Read more >
The Google Sheets API "clear" method prompts for a required ...
TROUBLESHOOTING: The Google Sheets API "clear" method prompts for a required value. ... Unknown name \\\"data\\\": Cannot find field.
Read more >
Node Google Docs REST API Batch update invalid JSON ...
When attempting to perform a batch update and I receive a Invalid JSON payload error; and trying to stringify JSON gives a 'missing...
Read more >
Invalid Json Payload Error Received When Performing A ...
Ask questionsGoogle sheet API v4 batchUpdate provide error : Invalid JSON. Unknown name data. I got an error by executing the batchUpdate function...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found