Google sheet api v4 post不会将数据附加到电子表格

时间:2017-01-20 12:47:37

标签: node.js google-sheets-api gapi

我正在使用nodejs模块尝试使用append method向Google电子表格添加数据:

   {
      spreadsheetId: '{spreadsheetId}',
      tableRange: 'Sheet1!A1:B18',
      updates: 
       { spreadsheetId: '{spreadsheetId}',
         updatedRange: 'Sheet1!A19' } 
    }

返回的响应如下:

{
  "spreadsheetId": "{spreadsheetId}",
  "tableRange": "Sheet1!A1:B17",
  "updates": {
    "spreadsheetId": "{spreadsheetId}",
    "updatedRange": "Sheet1!A18:B18",
    "updatedRows": 1,
    "updatedColumns": 2,
    "updatedCells": 2
  }
}

虽然我希望得到如下回复:

task myTask << {
    println "here's a task"
}
tasks.whenTaskAdded { task ->
if (task.name == 'assembleDebug') {
    task.dependsOn myTask 
}

1 个答案:

答案 0 :(得分:1)

由于回答了这个问题,我意识到我正在将正文传递给选项而不是使用资源字段:

trying to append row google sheets api

function addEventData(auth) {
  var sheets = google.sheets('v4');
  sheets.spreadsheets.values.append({
    auth: auth,
    spreadsheetId: spreadsheetId,
    range: 'Sheet1!A:B',
    valueInputOption:'RAW',
    insertDataOption:'INSERT_ROWS',
    alt:'json',
    resource:{
      values:[['xoxo', '12']]
    }
  },

  function(err, response){
    if(err){
      console.log('The api returned an error:'+err);
      return
    }
    console.log(response);

  })
}