Code used
var values = [
[
'value1','value2','value3'
]
];
var body = {
values: values
};
gapi.client.sheets.spreadsheets.values.update({
spreadsheetId: '1Lofhq9R7X5wzGvO7fMViN8D8q1W3fiNxO5jjP7XL_s0',
range: 'Sheet1!A1:A4',
valueInputOption:'RAW',
resource: body
}).then((response) => {
var result = response.result;
console.log(`${result.updatedCells} cells updated.`);
});
Error shown
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"valueInputOption\": Cannot bind query parameter. Field 'valueInputOption' could not be found in request message.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"valueInputOption\": Cannot bind query parameter. Field 'valueInputOption' could not be found in request message."
}
]
}
]
}
}
I've changed access settings of the google spreadsheet to allow anyone with it's link to view and edit it. This error is arising only when I'm trying to write into the spreadsheet, I'm able to read a spreadsheet using other functions.