GAS "The item with the specified ID could not be found or you do not have permission to access" error.

Asked 2 years ago, Updated 2 years ago, 73 views

I want to use GAS to retrieve the specified folder in my google drive, but every time I run a script, I get an error message saying, "I couldn't find an item with the specified ID or I don't have permission to access it."

In order to gain access, you have already added the email address of your GAS account on the Sharing settings page of that folder.

I still get the above error message, but I would appreciate it if you could tell me what are the possible causes.
I'm sorry to ask you a rudimentary question.

Here is the actual code.
The folder ID name contains the folder / or later string of the URL.

function myFunction(){
  var myFolder=DriveApp.getFolderById('folder ID name'); // Get folder
  Logger.log (myFolder.getName());
}

google-apps-script

2022-09-30 21:47

1 Answers

  • Incorrect folder ID
    • Mistake copying
    • The string you think is an ID is not actually an ID
    • The value of the variable holding the ID has changed without realizing it
  • The email address is incorrect
    • Adding the wrong email address when setting permissions
    • GAS is running on a different account than I expected
  • I do not intend to grant permission
    • The folder you handle on your browser and the folder you specify by ID are different
  • Mistake copying
  • The string you think is an ID is not actually an ID
  • The value of the variable holding the ID has changed without realizing it
  • Adding the wrong email address when setting permissions
  • GAS is running on a different account than I expected
  • The folder you handle on your browser and the folder you specify by ID are different

There are various possible causes, so I think it would be better to start by separating the causes.


2022-09-30 21:47

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.