typescriptgoogle-apps-scriptgoogle-drive-apiserver-error

Google App Script - Unexplained runtime error


I'm writing a Gmail extension with Google Apps Script. The extension uses the DriveApp class to save email attachments as Drive files.
The app worked just fine for the last few weeks. Yesterday, the following exception appeared:

Exception: We're sorry, a server error occurred. Please wait a bit and try again. [line: 10, function: getSubfolderByPath, file: FileMover]
Line 10 is: let curFolder = DriveApp.getFolderById(folderId);

The folderId variable is set correctly, I logged it and checked that the directory actually exists. I googled this obscure exception, and the only relevant info I found states that this might actually be an internal Google Drive problem, and that it might be related to some ongoing issue with the service. The app doesn't work for more then 24 hours, and I didn't find any notifications about ongoing issues.


Solution

  • SOLVED!
    Around the same time the problem appeared, I integrated the Google Apps Script project with my organisation's G Suite. When connecting the project to Google Cloud Platform, you are required to enable the specific Google APIs you are using.
    After enabling the Google Drive API everything worked as before.