How to do I locate a Google SpreadSheet ID?

JavaGoogle Apps-ScriptGoogle Sheets

Java Problem Overview


https://developers.google.com/apps-script/guides/rest/api#parameter_and_return_types

When using the Google Execution Api for Java, the ID of the spreadsheet isn't very easy to understand. Here is the code snippet:

// Initialize parameters for that function.
String sheetId = "<ENTER_ID_OF_SPREADSHEET_TO_EXAMINE_HERE>";
List<Object> params = new ArrayList<Object>();
params.add(sheetId);

Any Ideas on how to locate this. I run the Sheets api to return the id of a SpreadSheet but it returns a link, and when I use the https://spreadsheets.google.com/feeds/spreadsheets/*STRING* or just the STRING itself I still get: "code" : 404, "errors" : [ { "domain" : "global", "message" : "Requested entity was not found.", "reason" : "notFound"

Java Solutions


Solution 1 - Java

Found this deep inside the Apps Script API reference.

A spreadsheet ID can be extracted from its URL. For example, the spreadsheet ID in the URL https://docs.google.com/spreadsheets/d/abc1234567/edit#gid=0 is "abc1234567".

Solution 2 - Java

https://developers.google.com/sheets/api/guides/concepts

states that:

Every API method requires a spreadsheetId parameter which is used to identify which spreadsheet is to be accessed or altered. This ID is the value between the "/d/" and the "/edit" in the URL of your spreadsheet. For example, consider the following URL that references a Google Sheets spreadsheet:

https://docs.google.com/spreadsheets/d/1qpyC0XzvTcKT6EISywvqESX3A0MwQoFDE8p-Bll4hps/edit#gid=0

The ID of this spreadsheet is 1qpyC0XzvTcKT6EISywvqESX3A0MwQoFDE8p-Bll4hps.

So I just pulled up my spreadsheet and looked at the URL to find my ID.

Hope this helps!

Solution 3 - Java

I just created a hyperlink to the sheets and then copied that hyperlink to a text file and the link line shows the GID.

https://docs.google.com/spreadsheets/d/1TxNHS6vuse1is2Mw_hUs9wTDM6f095Y6pKLeltUfNzQ/edit#gid=1049871492

Then I created a pull down list in A52 and then made =IF() logic to go to the GIDs to go to those sheets.

=IF(A52="47QTCK18D0001",HYPERLINK("#gid=0","47QTCK18D0001"),IF(A52="47QTCK18D0002",HYPERLINK("#gid=1049871492","47QTCK18D0002") ....

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBoom3kView Question on Stackoverflow
Solution 1 - JavaBoom3kView Answer on Stackoverflow
Solution 2 - JavaSam EversView Answer on Stackoverflow
Solution 3 - JavaJeff SparksworthyView Answer on Stackoverflow