Get the spreadsheet key located in the url. Not ss.getId ()

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 does not work with Google-Drive-SDK. I can no longer use this identifier to open files using the Drive-SDK. It worked about 1 week ago, but the Drive-SDK now does not open the file.

The workaround is to use the identifier, which is in the url. Identifier after key =

https://docs.google.com/spreadsheet/ccc?key=0AkGlO9jJLGO8dHJrSE0wTEF2VXRSdGRlNVQaaVRad0E

But I want an automated way to get it, not a manual process. Since the spreadsheet is created using a template, so I have no way to find out the identifier. Thoughts, is there any way to get this?

Note 1: stackoverflow.com/questions/18583885/ states that problems with the Google Drive SDK should be sent to stackoverflow

Note 2: getUrl () and getKey () contain the same identifier as getId (), and not the key in the URL. So it looks like the key access has been removed, so I don't really hope so.

Edit

The drive code is Java, not 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();

, - . execute(), 404. , , google script. , URL- .

+1
2

, ,

function myFunction() {
// create a new spreadsheet workbook
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())
 }
+3

, "" "".

"" Spreadsheet, , , .

+1

Source: https://habr.com/ru/post/1537698/


All Articles