我目前正在尝试使用Google表格API v4修改给定电子表格的一行。更新请求的部分标准是传入" valueInputOption"作为请求的一部分。
目前,我正在使用API的Node.JS版本。到目前为止,我的要求是这样的:
var request = {
"spreadsheetId": '1O3jnpFXCdjA7NVE13ERTtqcL4pUWqxj-y_0GoYK2b2o',
"range": 'FighterZ Info!A' + index + ':G',
"resource": body,
"valueInputOption": "RAW",
"auth": authClient
};
但是,每当我执行请求时,都会遇到此错误:
{ Error: 'valueInputOption' is required but not specified
at new RequestError (/Users/jtelmo/Desktop/NorCal DBFZ Bot/node_modules/google-auth-library/lib/transporters.js:34:42)
at Request._callback (/Users/jtelmo/Desktop/NorCal DBFZ Bot/node_modules/google-auth-library/lib/transporters.js:96:27)
at Request.self.callback (/Users/jtelmo/Desktop/NorCal DBFZ Bot/node_modules/request/request.js:186:22)
at Request.emit (events.js:159:13)
at Request.<anonymous> (/Users/jtelmo/Desktop/NorCal DBFZ Bot/node_modules/request/request.js:1163:10)
at Request.emit (events.js:159:13)
at IncomingMessage.<anonymous> (/Users/jtelmo/Desktop/NorCal DBFZ Bot/node_modules/request/request.js:1085:12)
at Object.onceWrapper (events.js:254:19)
at IncomingMessage.emit (events.js:164:20)
at endReadableNT (_stream_readable.js:1062:12)
代码:400, 错误: [{message:&#39; \&#39; valueInputOption \&#39;是必需的但未指定&#39;, 域名:&#39;全球&#39;, 原因:&#39; badRequest&#39; }]}
我在这里做错了吗?我没有把这个valueInputOption键放在它应该去的地方吗?
答案 0 :(得分:0)
您正在使用字符串作为API请求对象中的属性名称:
var request = {
"spreadsheetId": '1O3jnpFXCdjA7NVE13ERTtqcL4pUWqxj-y_0GoYK2b2o',
"range": 'FighterZ Info!A' + index + ':G',
"resource": body,
"valueInputOption": "RAW",
"auth": authClient
};
将其更改为使用普通属性名称,如下所示:
var request = {
spreadsheetId: '1O3jnpFXCdjA7NVE13ERTtqcL4pUWqxj-y_0GoYK2b2o',
range: 'FighterZ Info!A' + index + ':G',
resource: body,
valueInputOption: "RAW",
auth: authClient
};
答案 1 :(得分:0)
这是V25(和V26)的错误,参考
https://github.com/google/google-api-nodejs-client/issues/964
即,将其更改为版本24.0.0并且它将按预期工作。