I am using the Google Docs API to update content in a document.
The document has a table of contents, but this doesn't update automatically after making changes in the document using the API.
The only method I've found, is to manually open the document and click the refresh icon next to the table of contents, which will update the TOC.
Is there a way to do this programatically, using the Google Docs API?
The Google Docs API does not make available a method that will allow you to automatically refresh the table of contents in a page programmatically. On top of this, without a TableOfContents already in a document, it is currently not possible to obtain links to heading paragraphs, as detailed on Google’s Issue Tracker. This means that elements can not be fetched to insert without manually pressing the refresh button in the document itself.
A feature request to generate and update a Table of Contents programmatically has been submitted here, which you can indicate is a problem you’re also experiencing and get updates by giving it a star.