ReferenceError: "Drive" is not defined

11,939

Solution 1

You have multiple issues:

  1. "Drive" is not defined" error, see this

Open menu from your script ( the place you start with Code.gs) and use : Resources - Advanced Google services and check on the Drive API v2

  1. Use files from drive to change and upload

    • your source code can identify the files and used ;
    • define the resources and blob ;
    • enable the Advanced Drive API Service: var file = Drive.Files.insert(resource, blob, ...) ;

Solution 2

I was having the same problem. It was resolved by adding Drive Services to the project. Snapshot attached to show how to do it.

Add Drive :

Add Services

Share:
11,939

Related videos on Youtube

Eric
Author by

Eric

Updated on June 04, 2022

Comments

  • Eric
    Eric almost 2 years

    In Google App Maker, I am writing a function in ServerScript that will convert a user-uploaded Excel spreadsheet to Google spreadsheet. I am using this piece of code (https://stackoverflow.com/a/35597644/9878092), but I am getting

    ReferenceError: "Drive" is not defined.

    I tried using the line of code that I got directly from the link:

    file = Drive.Files.insert(file, xlsxBlob, {
    

    and my own edited version:

    file = Drive.Files.update(file, ssFileID, xlsxBlob, {
    

    Where ssFileID is the file id of the pre-made Google Sheet I want to insert the data from a user-uploaded Excel spreadsheet into. How do I fix this error?

    • Markus Malessa
      Markus Malessa almost 6 years
      Did you make sure to enable the Drive API under App Settings>Advanced Services?
    • Eric
      Eric almost 6 years
      @MarkusMalessa Just enabled the Drive API, it solved the error! Thank you so much!
    • tehhowch
      tehhowch almost 6 years
      Make sure you read the links in answers, not just copy (and attribute) the code ;)