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

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

Comments

@wonderfly
Copy link
Contributor

@wonderfly wonderfly commented Jan 10, 2015

From InstantW...@gmail.com 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("CellMaster.com.au").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:

SpreadsheetApp.getActiveSpreadsheet().getId();

But it works fine with a manual copy of the spreadsheet key from the url, such as https://docs.google.com/spreadsheet/ccc?key=0AkGlO9jJLGO8dHJrSE0wTEF2VXRSdGRlNVQaaVRad0E 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: http://code.google.com/p/google-api-java-client/issues/detail?id=859

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

@wonderfly wonderfly commented Jan 10, 2015

From InstantW...@gmail.com on March 03, 2014 15:58:36

Workaround:
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();
Logger.log(id)
// get the ss file through Drive using spreadsheet id
var file = DriveApp.getFileById(id);
var driveid = file.getId();
Logger.log(driveid)
// open the spreadsheet using id of file
var ssfromdrive = SpreadsheetApp.openById(driveid);
Logger.log(ssfromdrive.getName()) http://stackoverflow.com/questions/21842456/get-the-spreadsheet-key-that-is-in-the-url-not-ss-getid

@wonderfly
Copy link
Contributor Author

@wonderfly wonderfly commented Jan 10, 2015

From dr.aries...@gmail.com 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
@drandreaskrueger
Copy link

@drandreaskrueger drandreaskrueger commented Apr 26, 2017

I get a

Error
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
@sduskis
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
Labels
imported priority: p2 🚨 type: bug
Projects
None yet
Development

No branches or pull requests

6 participants