1

我似乎无法将行正确导入 Google Fusion。我总是收到 503 后端错误。我的 Google Apps 脚本代码如下。

var getDataURL = ' https://www.googleapis.com/fusiontables/v1/tables/ {tableID} /import?key='+ {apiKey} ;

var ssDown = SpreadsheetApp.openById({Spreadsheet ID}).getDataRange().getValues();

var options = { "method" : "post", "contentType" : "application/json", "headers" : { "Authorization" : "Bearer" + {token} , "Accept" : "application/json", } , '编码' = '自动检测', '有效负载' = ssDown.toString(); } };

var output = UrlFetchApp.fetch(getDataURL,options).getContentText();

4

1 回答 1

1

这个问题是由我粗心的编码引起的。正确的代码是:

var getDataURL = 'https://www.googleapis.com/upload/fusiontables/v1/tables/{tableID}/import';
var options = { "method" : "post",
              "contentType" : "application/octet-stream",
              "headers" : {
                "Authorization" : "Bearer " + {token},
                "Accept" : "application/json",
              },
            }
var ssDown = SpreadsheetApp.openById({sheetID}).getDataRange().getValues().toString();
options.payload = ssDown;
var output = UrlFetchApp.fetch(getDataURL,options).getContentText();
于 2013-05-19T10:42:17.013 回答