Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Whenever I run the following function

    function getDatabases(){
      var files = DriveApp.getFilesByType(MimeType.GOOGLE_SHEETS);
      var amount = 0;
      while (files.hasNext()){
        if((files.next().getName()).indexOf("Database") > -1){
          amount++;
        }
      }
      return amount;
    }

I get this error:

Error Message

This suddenly started about a month and a half ago. The same code was working earlier so I thought I reached a quota limit but that was not the case.

like image 298
David Fahim Avatar asked Jun 03 '20 14:06

David Fahim


Video Answer


3 Answers

got my solution In the script -> Resources -> Advanced google services -> turn on Drive API Click in below message " Google Cloud Platform API Dashboard" to open de cloud project for the script. With the project selected, search in the search bar "Drive API" -> ENABLE, do the same for "Google Drive API". Done, no more "we're are sorry server error" for DriveApp functions in the script. Also: I enabled other APIs and advanced services Drive Activity API, just in case...

like image 116
Nicolás Paulino Avatar answered Oct 16 '22 15:10

Nicolás Paulino


I ran into this issue too...

Like Nicolás Paulino mentioned, check your "Advanced Google Services" are turned on with the Apps Script Editor UI..

As stated...from the apps script editor..

  • select the "Resources" menu item
  • then "Advanced Google Services"
  • then find all/all related services and toggle them on.

Then head to ... https://console.cloud.google.com/apis/library?project={yourProjectId}

Click on the menu (top-left)

  • hover on "Apis & Services"
  • click "Library"
  • search for any/all related APIs you're using
like image 39
SourceFli Avatar answered Oct 16 '22 16:10

SourceFli


I've just had your same issue and it took me forever to fix it. What worked for me was to create a copy of the spreadsheet with the bound script. After authorising everything again in the copy, it worked. Hope it helps!

like image 1
res_cogitans Avatar answered Oct 16 '22 15:10

res_cogitans