Google api version version 25 is giving followin e

2019-04-17 10:47发布

Although I am specifying valueInputoption but still i am getting this error. I followed google sheet`s quickstart.js tutorial for authentication.

  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");
  }
});
}

2条回答
太酷不给撩
2楼-- · 2019-04-17 11:19

First thing I suggest that you change is to use apostrophe (') instead of double quotes ("). If that doesn't work check my snippet taken from Sheets API NodeJS Quickstart combining it with the concepts of spreadsheets.values.append:

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"]
          ]
      }
    });
}

Let me know if it works for you.

查看更多
乱世女痞
3楼-- · 2019-04-17 11:26

Looks like it might be an issue with v^25.0. Switching to v24.0.0 resolved the issue for me:

... "dependencies": { "googleapis": "24.0.0", }, ...

https://gist.github.com/iaincollins/43302ea047d4a77e6605350598d160c1

查看更多
登录 后发表回答