node.js - Unable to create a new spreadsheet with the Google Sheets API -
i'm using googleapis package create new google spreadsheet , fails. same request works when use web-based tools in google api documentation.
google.prototype.createsheet = function(filename, callback) { var services = google.sheets('v4'); services.spreadsheets.create({ properties : {title:filename}, auth : this.auth }, function(err,response) { if( err ) { console.log('error : unable create file, ' + err); return; } else { console.dir(response); } }); }
the result,
error : unable create file, error: invalid json payload received. unknown name "properties": cannot bind query parameter. field 'properties' not found in request message.
i've tried using property name of "resource" instead of "properties" because found in other sheets endpoints. didn't work resulted in both different error message different api request when debug googleapis code.
error : unable create file, error: invalid json payload received. unknown name "title" @ 'spreadsheet': cannot find field.
i've tried creating file using drive api without success.
wow. turns out answer hybrid of 2 experiments. encapsulating properties inside of resource block.
google.prototype.createsheet = function(filename, callback) { var services = google.sheets('v4'); services.spreadsheets.create({ resource : {properties:{title:filename}}, auth : this.auth }, function(err,response) { if( err ) { console.log('error : unable create file, ' + err); return; } else { console.dir(response); } }); }
i don't see anything in google api documentation indicates right way send request isn't comforting though it's effective.
Comments
Post a Comment