Google Docs API: Image insertion fails with rate limit error

Viewed 124

I use the Java Google Drive API to upload a document consisting of text with about 100 images. I produce a request like this:

List<Request> requests = new ArrayList<>();
for (...) {
   requests.add(new Request().setInsertText(...));
   requests.add(new Request().setInsertInlineImage(...));
}
BatchUpdateDocumentRequest body = new BatchUpdateDocumentRequest().setRequests(requests);
BatchUpdateDocumentResponse response = service.documents().batchUpdate(id, body).execute();

This has worked well for quite a while. However, since today, the tool fails with

com.google.api.client.googleapis.json.GoogleJsonResponseException: 429 Too Many Requests
{
  "code" : 429,
  "errors" : [ {
    "domain" : "global",
    "message" : "Resource has been exhausted (e.g. check quota).",
    "reason" : "rateLimitExceeded"
  } ],
  "message" : "Resource has been exhausted (e.g. check quota).",
  "status" : "RESOURCE_EXHAUSTED"
}

The quota page shows that I am well within the quota for write requests. And indeed, if I don't include images, I can write additional documents. But as soon as I add a single image, the request fails.

Is there a hidden quota somewhere? Is there a better way to do this?

1 Answers

The problem is in the document that you are using at that moment, try to make a new document, and run the batch update again with the new document id. this would solve the image insertion fail.

Related