I have code that works well in one worksheet but not another. Comes out:
"Exception: Sorry, a server error occurred. Please wait a moment and try again."
Maybe I'm calling UrlFetchApp
too many times... is there a way to call UrlFetchApp
once for what I'm looking for based on my code? On the sheet where the code works fine it returns the response message and all 3 files in a Drive folder.
var exchange = UrlFetchApp.fetch('https://www.myweb.com/', options);
var response = exchange.getContentText();
var cell = ss.getRange('A5');
cell.setValue(response);
var URL = response.match(/link\|(.+)\|/)[1];
var url1 = URL + '.pdf';
var url2 = URL + '.xml';
var url3 = URL + '.cdr';
var pdf = UrlFetchApp.fetch(url1).getBlob().setName(name + '.pdf');
var xml = UrlFetchApp.fetch(url2).getBlob().setName(name + '.xml');
var cdr = UrlFetchApp.fetch(url3).getBlob().setName(name + '.cdr');
var folder = DriveApp.getFolderById('myfolder');
folder.createFile(pdf);
folder.createFile(xml);
folder.createFile(cdr);