Question

i am using google Apps Script to do some report automation of google analytics.

Therefore I'm regularly sending out sheets as a pdf via email. It worked for months but since 2 weeks it doesn't seem to work anymore. I tried to call the sending manually and per trigger. Both methods lead to the same error message:

"We're sorry, a server error occurred. Please wait a bit and try again"

The line of code that is causing the error is the first one of the two:

var pdf = DocsList.getFileById(newSpreadsheet.getId()).getAs('application/pdf').getBytes();

attach.push({fileName:PDF_NAME,content:pdf, mimeType:'application/pdf'});

If I leave out the statement

.getBytes() 

the error message disappears but the process isn't working anymore.

Can anyone help me with this problem? I looked up the methods but none of them seems to be depracted or wrong at it's place so I am a bit confused why it suddenly stopped working.

Was it helpful?

Solution

It seems I have found the reason for the problem. Since the new version of Google Docs Spreadsheet has launched every newly created spreadsheet uses the new version. Some methods don't function as one migth expect, like this one: DocsList.File.getAs(contentType) Google says: >"These methods cannot generate PDFs from spreadsheets created in the new version of Sheets." So as I am always creating a new spreadsheet and then copy the data sheet into the new spreadsheet to send the report this won't work since the new version has launched...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top