1

My goal is to publish a Google Sheet document to the web and get the link using Google Sheets API.

I managed to publish it using this advice and now it says "published" in File -> Publish to the web tab. However, the link given on this tab is different from the original file id, and I don'k know how to get it with API.

Vasily
  • 2,192
  • 4
  • 22
  • 33

1 Answers1

2

Unfortunately, the URL of https://docs.google.com/spreadsheets/d/e/### Not fileId ###/pubhtml retrieved when the spreadsheet is published cannot be directly retrieved. At Drive API v2, there was publishedLink in Revision as a field. But I confirmed that it cannot be used now. publishedLink was removed by updating Drive API from v2 to v3. This might affect to the situation. But I'm not sure about this.

So how about using the following URL as a workaround? In this case, you can access the published spreadsheet using file ID.

https://docs.google.com/spreadsheet/pub?key=### fileId ###

Reference :

If I misunderstand your question, I'm sorry.

Tanaike
  • 181,128
  • 11
  • 97
  • 165
  • 1
    @Vasily Was my answer useful for you? If you have problems for my answer yet, feel free to tell me. Such information helps me to study. Also I think that it helps other users to know the situation as an information. – Tanaike Feb 05 '18 at 22:31
  • I appreciate your help very much. Your answer is valid, however I actually used example from [this page](https://apievangelist.com/2017/07/11/when-you-publish-a-google-sheet-to-the-web-it-als-becomes-an-api/) that also worked for me: `https://docs.google.com/spreadsheets/d/[sheet_id]/pubhtml` – Vasily Feb 07 '18 at 08:41
  • @Vasily Thank you for your additional information. I could study from your question. Thank you, too. – Tanaike Feb 07 '18 at 11:53