JavaScriptによるhttpリクエストでGoogleスプレッドシートのセルを読み書きしようとしています。「読み取り」操作は機能しますが、「書き込み」操作は失敗します。「書き込み」操作のコードでどの部分を変更する必要があるかを指摘してください。
私が従った書き込み例はここからhttps://developers.google.com/google-apps/spreadsheets/であり、機能していません。
私の読み取り操作(これは機能しています):
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);
私の書き込み操作(これは機能していません):
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);
書き込み操作は常にhttp_request.status = 0
コールバック関数で受け取りますprocess_cellrw()
。
私の環境は Windows 7 + Chrome ブラウザです。Android + Webkit でもテストしましたが、まだ失敗します。
リストフィードで行を追加することもテストしましたが、 receive でも失敗しますhttp_request.status = 0
。