I have the following code, running in Google Apps Script. The code attempts to take a range of a spreadsheet and save it as a PDF:
var range = sheet.getRange("A586:K" + lastRow);
// Get the currently active spreadsheet URL (link)
var ss = SpreadsheetApp.getActiveSpreadsheet();
var pdfBlob = DriveApp.getFileById(ss.getId()).getAs('application/pdf');
pdfBlob.setName('test.pdf');
// Save the PDF to your Google Drive.
var folder = DriveApp.getFolderById("1EJIzvW-oOnFfFOopiAAsudhbHsF5FGKz");
var file = folder.createFile(pdfBlob);
When I run the code, it runs for a while, then gives me the error:
We're sorry, a server error occurred. Please wait a bit and try again
Any tips on what might be going on?