pythongoogle-apigoogle-sheets-apigoogle-python-api

Publish Google Sheet document to the web using Google Sheets API


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.


Solution

  • 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.