的Google Sheets宏错误请求失败https://drive.google.com返回代码403



运行宏时收到以下错误消息:

异常:的请求失败https://drive.google.com返回代码403。截断的服务器响应:对不起。。。body{font-family:verdana,arial,…(使用muteHttpExceptions选项检查完整响应(

似乎在URLFetchApp功能处停止:

var ss2 = SpreadsheetApp.getActive();
var url2 = 'https://drive.google.com/uc?export=download&id=1H5B1JAJX7xfxOW8b4kgEs3C2eFphWuJQ'; 
var file2 = UrlFetchApp.fetch(url2); // get feed

var csv2 = file2.getBlob().getDataAsString();
var csvData2 = CSVToArray(csv2); // see below for CSVToArray function
var sheet2 = ss2.getSheetByName('playerData'); //Replace this with the sheetname you want the data to appear in
for (var i2 = 0, lenCsv2 = csvData2.length; i2 < lenCsv2; i2++) {
sheet2.getRange(i2 + 1, 1, 1, csvData2[i2].length).setValues(new Array(csvData2[i2])); 
} 

尝试使用{muteHttpExceptions:true}

function myFunction() {
var ss2 = SpreadsheetApp.getActive();
var url2 = 'https://drive.google.com/uc?export=download&id=1H5B1JAJX7xfxOW8b4kgEs3C2eFphWuJQ'; 
var file2 = UrlFetchApp.fetch(url2, {muteHttpExceptions: true });
var csv2 = file2.getBlob().getDataAsString();
console.log(csv2)
} 

它有效!

相关内容

  • 没有找到相关文章

最新更新