Friday, 26 May 2017

I can't insert value in Google SpreadSheets (use nodejs & module googleapis)

I have this code

Is a example of Google Sheets API V4 https://developers.google.com/sheets/api/quickstart/nodejs

But i need insert a value in a spreadsheet, in the doc i see the append method for this case

I have the following function to append (Use googleapis library)

function addValues(auth) {
var sheets = google.sheets('v4');

val = Object.assign({
  majorDimension: "ROWS",
  values: [
    ["Hello","Google","Sheets"]
  ]
},sheets.spreadsheets.values)

//console.log("",val)

val.append({
  auth: auth,
  range: "A1",
  spreadsheetId: '1bhXbigMkNyTgKFVePZIwP5VZE1hN0XcvTRdeFdUSUdo',
  includeValuesInResponse: true,
  insertDataOption: "INSERT_ROWS",
  responseDateTimeRenderOption: "FORMATTED_STRING",
  responseValueRenderOption: "UNFORMATTED_VALUE",
  valueInputOption: "RAW"
}, function(err, response){
  if (err) {
    console.log('The API returned an error: ' + err);
    return;
  }
  console.log(response);
  })
}

...and isn't working

Console return the following messagge

{ spreadsheetId: '1bhXbigMkNyTgKFVePZIwP5VZE1hN0XcvTRdeFdUSUdo',
tableRange: '\'Hoja 1\'!A1:C2',
updates:
{ spreadsheetId: '1bhXbigMkNyTgKFVePZIwP5VZE1hN0XcvTRdeFdUSUdo',
updatedRange: '\'Hoja 1\'!A3',
updatedData: { range: '\'Hoja 1\'!A3', majorDimension: 'ROWS' } } }

It looks like the "values" array is not sent

My complete code is in https://github.com/aaroncadillac/google-sheets-api/tree/test

The important file is quick.js, I hope you can help me

Bye!



via Aarón Gabriel Hinojosa Maya

No comments:

Post a Comment