ReferenceError: "Disk" not defined. (line 16, file "Code") in the Google application script

When I try to use the google drive link it always shows a ReferenceError: "Drive" is not defined. (line 16, file "Code").

+6


source to share


3 answers


I resolve this error by going to:

ResourcesExtended service the GoogleEnable Drive Api



enter image description here

Note: you need to enable Drive Api in Google Console

+14


source


In addition to the sour answer:

If you have multiple libraries, it seems that you need to enable the Drive API in every Google Apps Scripting project (not to be confused with Google Cloud Project) that the Drive API can use even if the actual API call is in another Application Scripting project ...

For example, let's say you have two application script projects, Util and DoStuffWithSheets. Util contains a function calling Drive API. DoStuffWithSheets imports Util (by going to Resources -> Libraries). DoStuffWithSheets has a function that gets triggered when you edit a sheet or whatever and calls the Util function that uses the Drive API.



NOT enough to enable Drive API in Util; this should be included in DoStuffWithSheets.

This refers to the Google Apps Script Libraries, which belong to the same Google cloud project that also includes the Drive API. I have not tested this for libraries that belong to various GC projects.

0


source


After getting permission for Drive API I get

"Type error: Drive.Files.insert is not a function"

Mistake.

Could you help me with this?

Thank,

0


source







All Articles