1

Our write request rate barely exceeds 1 request per 100s, yet we started getting this 429 error at every request for this method since this morning. Our write request rate is 3 requests / 100s, during 8am - 5am and never exceeds that (9 requests every 5 minutes or so). Totaling around 50k requests for the whole month. So nowhere near any of Google's default quota limits. What are we missing?

The response body is

"error": {
    "code": 429,
    "message": "Resource has been exhausted (e.g. check quota).",
    "errors": [
      {
        "message": "Resource has been exhausted (e.g. check quota).",
        "domain": "global",
        "reason": "rateLimitExceeded"
      }
    ],
    "status": "RESOURCE_EXHAUSTED"
  }

Relevant part of the source code is (part of) a PHP class representing a console command:

class UpdatePresentations extends CommandUsingDb
{

    /** @var Google_Service_Slides */
    private $slides;

    /** @var Google_Service_Slides_Request[] */
    private $requests = [];

    private function updateChart(Google_Service_Slides_Presentation $presentation, OutputProvider $outputProvider, Site $site)
    {
        // refresh charts in slides
        foreach ($presentation->getSlides() as $index => $slide) {
            foreach ($slide->getPageElements() as $element) {
                /** @var Google_Service_Slides_PageElement $element */
                $chart = $element->getSheetsChart();

                if ($chart instanceof Google_Service_Slides_SheetsChart) {
                    $this->requests[] = new Google_Service_Slides_Request([
                        'refreshSheetsChart' => [
                            'objectId' => $element->getObjectId(),
                        ],
                    ]);
                }
            }
        }
    }

  private function flush(Google_Service_Slides_Presentation $presentation)
    {
        if (empty($this->requests)) return;

        $batchUpdateRequest = new Google_Service_Slides_BatchUpdatePresentationRequest();
        $batchUpdateRequest->setRequests($this->requests);
        $this->slides->presentations->batchUpdate($presentation->presentationId, $batchUpdateRequest);
   }
}
  • Could you please provide the code related to the request you're making, in order to reproduce this? – Iamblichus Jul 23 '20 at 10:43
  • I tried to add the relevant part of the PHP console command that takes a google presentation as an argument, and updates slides in it. – Joris van Eil Jul 23 '20 at 12:28
  • I cannot reproduce this, I'm refreshing a chart successfully. How many charts and slides do you have in your presentation? – Iamblichus Jul 23 '20 at 13:40
  • 1
    I'm having this issue too and it seems to be presentation-specific. I can copy the exact code/presentation entirely to a new project & presentation then run it without problems, but once I point the newly copied code to run on the original presentation id, I run into the 429. Are you able to replicate the error by starting a new project? – SSB Jul 28 '20 at 06:34

1 Answers1

1

The problem is in the document that you are using at that time, try to make a new document, and run the batch update again with the new document id. this would solve the rateLimitExceeded problem (when actually it hasn't even reach the limit).