Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drive.file().get(key) fails with spreadsheet keys from google-apps-script #859

wonderfly opened this issue Jan 10, 2015 · 4 comments
imported priority: p2 🚨 type: bug


Copy link

@wonderfly wonderfly commented Jan 10, 2015

From on February 16, 2014 23:18:51

Version of google-api-java-client (e.g. 1.15.0-rc)? v2-rev82-1.15.0-rc Java environment (e.g. Java 6, Android 2.3, App Engine)? App-Engine Describe the problem. Was working fine, then stopped working.

    Drive driveService = new Drive.Builder(TRANSPORT, JSON_FACTORY, credential).setApplicationName("").build();
    File file = driveService.files().get(this.spreadsheetKey).execute();

Just noticed it now fails. I think it broke sometime in the last week or so. It fails with the execute(), it produces a 404 error. It gives the error when I use with the short spreadsheetKey that is produced by google apps script. The key produced by this google-apps-script code:


But it works fine with a manual copy of the spreadsheet key from the url, such as Note: the error is happening with old style spreadsheets, the 400,000 cell spreadsheets. I am not using the new style as they don't support GData yet. How would you expect it to be fixed? I don't want getting the key to be a manual process. So hopping you will make it work again. I suspect this stopped working in the last week, but the last time I am sure it worked was about be about 3 weeks ago.

Original issue:

@wonderfly wonderfly added type: bug imported priority: p2 2–5 stars labels Jan 10, 2015
@wonderfly wonderfly self-assigned this Jan 10, 2015
Copy link
Contributor Author

@wonderfly wonderfly commented Jan 10, 2015

From on March 03, 2014 15:58:36

in google apps script: "var driveid = file.getId();" gives the long spreadsheet key that is in the URL

var ss = SpreadsheetApp.create("Test");
var id = ss.getId();
// get the ss file through Drive using spreadsheet id
var file = DriveApp.getFileById(id);
var driveid = file.getId();
// open the spreadsheet using id of file
var ssfromdrive = SpreadsheetApp.openById(driveid);

Copy link
Contributor Author

@wonderfly wonderfly commented Jan 10, 2015

From on April 22, 2014 18:44:51

This "workaround" doesn't avoid the "manual process" that the OP wanted to avoid. In the example's case, you are getting the ID from a .create method, but what about files that already exist? It seems now you have to first retrieve the user's list of spreadsheet files, and then parse out the key from that list. Is there a "best" practice for retrieving the key of a google spreadsheet?

@wonderfly wonderfly removed their assignment May 19, 2016
Copy link

@drandreaskrueger drandreaskrueger commented Apr 26, 2017

I get a

You do not have permission to call getFileById (line ___).

@mattwhisenhunt mattwhisenhunt added status: investigating and removed priority: p2 type: bug labels Feb 6, 2018
@mattwhisenhunt mattwhisenhunt added type: bug priority: p2 and removed status: investigating labels Jun 6, 2018
@JustinBeckwith JustinBeckwith added the 🚨 label Jun 8, 2018
Copy link

@sduskis sduskis commented Mar 8, 2019

I'm closing this due to staleness. Please open a new issue if this is still a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
imported priority: p2 🚨 type: bug
None yet

No branches or pull requests

6 participants