Reputation: 1331
I have a google spreadsheet which is both published and available for anyone to edit. I'm able to retrieve the cell-based results, but when I try to update the cell I am unable to do so. I have also tried using the authenticated result but still no luck. Not sure how to proceed here, Any ideas what I am doing wrong.
var https = require('https');
var opt = {
host: "spreadsheets.google.com",
path: "/feeds/cells/key/od6/public/full/R2C4",
method:"PUT"
};
var request = https.request(opt, function(res){
res.setEncoding('utf8');
console.log('the header os '+ JSON.stringify(res.headers));
var XMLoutput='';
res.on('data',function(chunk){
XMLoutput+=chunk;
});
res.on('end',function(){
console.log('the data is '+ XMLoutput);
});
});
request.on('error',function(e){
console.log('the error is '+ e);
});
request.write('<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gs="http://schemas.google.com/spreadsheets/2006">'+
'<id>https://spreadsheets.google.com/feeds/cells/key/od6/public/full/R2C4</id>'+
'<link rel="edit" type="application/atom+xml" href="https://spreadsheets.google.com/feeds/cells/key/od6/public/full/R2C4"/>'+
'<gs:cell row="2" col="4" inputValue="someValue"/>'+
'</entry>');
request.end();
Upvotes: 0
Views: 596
Reputation: 1331
I finally got it working; I had to use the Authorization key correctly. Hope the below code helps!
var https = require('https');
var opt = {
host: "spreadsheets.google.com",
path: "/feeds/cells/key/od6/private/basic/R2C4",
method:"PUT",
headers : {"content-type":"application/atom+xml","Authorization":"GoogleLogin Auth=actualAuthkey","GData-Version": "3.0","If-Match": "*"}
};
var request = https.request(opt, function(res){
res.setEncoding('utf8');
console.log('the header os '+ JSON.stringify(res.headers));
var XMLoutput='';
res.on('data',function(chunk){
XMLoutput+=chunk;
});
res.on('end',function(){
console.log('the data is '+ XMLoutput);
});
});
request.on('error',function(e){
console.log('the errir is '+ e);
});
request.write('<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gs="http://schemas.google.com/spreadsheets/2006">'+
'<id>https://spreadsheets.google.com/feeds/cells/key/private/basic/R2C4</id>'+
'<link rel="edit" type="application/atom+xml" href="https://spreadsheets.google.com/feeds/cells/key/od6/private/basic/R2C4"/>'+
'<gs:cell row="2" col="4" inputValue="xyz"/>'+
'</entry>');
request.end();
Upvotes: 2