虽然我指定了valueInputoption但是我仍然收到此错误。我按照谷歌工作表的quickstart.js教程进行身份验证。
function appendData(auth) {
var sheets = google.sheets('v4');
values: [ ["Void", "Canvas", "Website"], ["Paul", "Shan", "Human"] ];
var body = {
values: this.values
};
sheets.spreadsheets.values.append({
auth: auth,
spreadsheetId: '13QPQj1Ot0oBJms2eQzrKahwzGt13JxQkqf54j2zk3jI',
range: 'Sheet1!A2:B', //Change Sheet1 if your worksheet's name is
//something else
valueInputOption: "USER_ENTERED",
insertDataOption: 'INSERT_ROWS',
resource: body
}, (err, response) => {
if (err) {
console.log('The API returned an error: ' + err);
return;
} else {
console.log("Appended");
}
});
}
答案 0 :(得分:2)
看起来它可能是v ^ 25.0的问题。切换到v24.0.0解决了我的问题:
...
"dependencies": {
"googleapis": "24.0.0",
},
...
https://gist.github.com/iaincollins/43302ea047d4a77e6605350598d160c1
答案 1 :(得分:0)
我建议您更改的第一件事是使用撇号(')而不是双引号(“)。如果这不起作用,请检查我从Sheets API NodeJS Quickstart获取的片段与{{3}的概念相结合}}:
function appendToSheet(auth) {
var sheets = google.sheets('v4');
sheets.spreadsheets.values.append({
auth: auth,
spreadsheetId: 'MY_SPREADSHEET_ID',
range: 'rawSheet!A:B',
valueInputOption: 'USER_ENTERED',
insertDataOption: 'INSERT_ROWS',
resource: {
"range": "rawSheet!A:B",
"values": [
[ "Conor","McGregor"]
]
}
});
}
让我知道它是否适合你。