2
votes

On March 2014, Google spreadsheet upgraded to Google sheets.

With Google Spreadsheet API v3 (java):

  • on sheet created on old version, the function gsService."oldsheet".getKey() return a 23 length key.
  • on sheet created on new version, the function gsService."newsheet".getKey() return a 44 length key.

My problem is the following.. I would like to use Drive API to retrieve a file using key previously requested from Google Spreadsheet API.

So, with Drive API:

driveService.files.get(sheetKey);

This works fine with the newest version of a Google spreadsheet file (post-March 2014) but returns a "not found" result on an older version of a Google spreadsheet file (pre-March 2014).

How can I convert old key to new key [on server side]?

1

1 Answers

0
votes

Spreadsheet key that works with drive:

I had a problem that sounds the same as this. I switch to using a key created with google apps script.

function getSpreadsheetURLKey() {
  var spreadsheetId = SpreadsheetApp.getActiveSpreadsheet().getId();
  var spreadsheetDriveFile = DriveApp.getFileById(spreadsheetId);
  var spreadsheetURLKey = spreadsheetDriveFile.getId();
  return spreadsheetURLKey;
}