We use the Google Drive SDK to monitor a folder of spreadsheets for changes. When a change happens, we download the file to our servers and convert it to JSON for further use.
Since a file may contain multiple sheets, we go through this process to extract all sheets:
- Download the
embedLink
from thedrive#file
resource and parse the HTML to extract thegid
of each sheet. (Similar to the approach used here.) - Download each individual sheet as CSV by appending
?gid=...
to thetext/csv
URL from theexportLinks
field.
Recently we've been seeing 429 Too Many Requests
errors, especially if the file gets big enough. According to the API console we're not close to the quota limit, so presumably export links are not counted as API requests, but is rate limited some other way. Exporting the sheet manually – as a different user from the one used against the Drive API – works fine.
Is there a way to find the gid
of each sheet in a file without downloading the full embedHTML
? If not, is there some way to avoid hitting the download limit?
EDIT: This incorrectly closed issue seems to deal with the problem of finding the gids of a spreadsheet file.
UPDATE: I've worked around this issue by parsing the XLSX export instead of the CSVs. Haven't seen the problem since.