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": {
"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."
}
]
}
]
}
}
我已更改了Google电子表格的访问设置,以允许任何具有其链接的人查看和编辑它。仅当我尝试写入电子表格,并且能够使用其他功能读取电子表格时,才会出现此错误。
我没有正确指定API所需的授权范围(在调用update函数之前)。使用https://www.googleapis.com/auth/spreadsheets
代替后错误已修复https://www.googleapis.com/auth/spreadsheets.readonly
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句