How to get the spreadsheet ID that is in the URL.
I know about using SpreadsheetApp.getActiveSpreadsheet().getId() and SpreadsheetApp.getActiveSpreadsheet().getUrl()
But getId()/getUrl()/getKey() now fails with Google-Drive-SDK. I am no longer able to
use this ID to open files with the Drive-SDK. It was working about 1 week ago, but the Drive-SDK now fails to open the file.
A workaround is to use the ID that is in the URL. The id after key=
https://docs.google.com/spreadsheet/ccc?key=0AkGlO9jJLGO8dHJrSE0wTEF2VXRSdGRlNVQaaVRad0E
But I want an automated way to get it, not
a manual process. As the spreadsheet is being created using a template, so I don't have a way to know the ID. Thoughts, is there a way to get it?
Note 1: stackoverflow.com/questions/18583885/ says Google Drive SDK issues should be posted to stackoverflow
Note 2: getUrl() and getKey() contains the same ID as getId() not the key in the URL. So it looks like access to the key has been removed, so am not holding out much hope.
Edit
The drive code, is Java rather than google-apps-script. version 1.15.0-rc
Drive driveService = new Drive.Builder(TRANSPORT, JSON_FACTORY, credential).setApplicationName("CellMaster.com.au").build();
File file = driveService.files().get(this.spreadsheetKey).execute();
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. But it still works fine when I use the browser URL key value.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…