I have a script below which export on a daily basis a sheet in CSV. This script was working very well until yesterday. I have now an error. Could you help me to understand why it is happening now?
function saveAsCSV() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var ssname = ss.getName();
var sheet = ss.getSheetByName("xxxx_sales_daily");
var folder = DriveApp.getFolderById("xxxxxxx");
var curDate = Utilities.formatDate(new Date(), "GMT-4", "ddMMyyyy");
var fileName = "XX_" + curDate + ".csv";
var url = "https://docs.google.com/spreadsheets/d/" + ss.getId() + "/export?
exportFormat=csv&format=scsv";
var token = ScriptApp.getOAuthToken();
var response = UrlFetchApp.fetch(url + sheet.getSheetId(), {
headers: {
'Authorization': 'Bearer ' + token
}
});
var csvData = Utilities.parseCsv(response.getBlob().getDataAsString());
var outputData = csvData.map(r => r.join("|")).join("\n");
folder.createFile(fileName, outputData, MimeType.PLAIN_TEXT);
}
The detail of the error says that it is coming from this line :
var response = UrlFetchApp.fetch(url + sheet.getSheetId(), {
Does Google change anything? Best regards J