I am trying to read and write a cell in google spreadsheet with http request from javascript. The read operation works, but the write operation fails. Please help indicate which part I should change in my write operation code.
An example of the post I followed is here https://developers.google.com/google-apps/spreadsheets/ and it does not work.
My read operation (this works):
http_request.onreadystatechange = function() { process_cellrw(http_request); }; http_request.open('GET',"https://spreadsheets.google.com/feeds/cells/0Aqed....RHdGc/od6/private/full/R1C1", true); http_request.setRequestHeader('Authorization','Bearer ' + strAccessToken); http_request.send(null);
My write operation (this does not work):
var testxml = ['<entry xmlns="http://www.w3.org/2005/Atom" <br> xmlns:gs="http://schemas.google.com/spreadsheets/2006">',<br> '<id>https://spreadsheets.google.com/feeds/cells/0Aqed....RHdGc/od6/private/full/R1C1</id>',<br> '<link rel="edit" type="application/atom+xml"<br> href="https://spreadsheets.google.com/feeds/cells/0Aqed....RHdGc/od6/private/full/R1C2/9zlgi"/>',<br> '<gs:cell row="1" col="1" inputValue="xxxx"/>',<br> '</entry>'].join('');<br> http_request.onreadystatechange = function() { process_cellrw(); }; http_request.open('PUT',"https://spreadsheets.google.com/feeds/cells/0Aqed....RHdGc/od6/private/full/R1C2/9zlgi"); http_request.setRequestHeader('Authorization','Bearer ' + strAccessToken); http_request.setRequestHeader('GData-Version','3.0'); http_request.setRequestHeader('Content-Type', 'application/atom+xml'); http_request.setRequestHeader('If-Match','*'); http_request.setRequestHeader('Content-Length', testxml.length.toString()); http_request.send(testxml);
A write operation always takes http_request.status = 0 in the callback function process_cellrw() .
My environment is the Windows 7 + Chrome browser. I also tested it on Android + Webkit, still failed.
I also tested to add a line to the list, it also fails to get http_request.status = 0 .