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
Yup, I had the same problem. Check what API call you're making; you're calling spreadsheets.batchUpdate instead of spreadsheets.values.batchUpdate.
@marcantoineTrehin Like @ehgoodenough said, you probably mean to be calling spreadsheets.values.batchUpdate, but in the code you posted you're actually calling spreadsheets.batchUpdate.
Getting the same error. Same code above but using spreadsheets.values.batchUpdate. Anyone have a working example of the options argument?
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);
});
Here are more examples of how to call batchUpdate:
https://github.com/gsuitedevs/node-samples/blob/master/sheets/snippets/snippets.js#L74
Feel free to file an issue on our Spreadsheets examples if you find problems there.
@jmdobry: Thank you!! I use the nodejs Google API library and using resources finally made the API call possible!
Most helpful comment
The payload of the request (not the parameters) need to be nested under a
resourceproperty: