Referenceerror: "drive" Is Not Defined. (line 16, File "code") In Google App Script
Solution 1:
I've solves this error by go to:
Resources -> Advanced Google Services -> Enable Drive Api
Note: you need to Enable Drive Api in Google Console
Solution 2:
In addition to Sour's answer:
If you have multiple libraries, it seems that you have to enable the Drive API in every Google Apps Script Project (not to be confused with a Google Cloud Project) that might use the Drive API, even if the actual call to the API occurs in a different Apps Script Project.
For example, say you have two Apps Script Projects, Util and DoStuffWithSheets. Util contains a function with a call to the Drive API. DoStuffWithSheets imports Util (by going to Resources -> Libraries). DoStuffWithSheets has a function that is triggered by an edit to a Sheet or whatever, and it calls the Util function that uses the Drive API.
It is NOT sufficient for the Drive API to be enabled in Util; it has to be enabled in DoStuffWithSheets.
This goes for Google Apps Script libraries which belong to the same Google Cloud Project in which the Drive API is also enabled. I haven't tested it for libraries which belong to different GC Projects.
Post a Comment for "Referenceerror: "drive" Is Not Defined. (line 16, File "code") In Google App Script"