0

I have to send a bunch of events with a Batch Request to Google Calendar API, can anyone explain to me how to do it in PHP Laravel? I want to Update, Insert, and Delete calendar events with batch.

Actually, I am facing this "Rate Limit Exceeded" error while using the Google Calendar API. If I use Batch call then this error will minimize

local.ERROR: {
"error": {
 "errors": [
  {
   "domain": "usageLimits",
   "reason": "rateLimitExceeded",
   "message": "Rate Limit Exceeded"
  }
 ],
 "code": 403,
 "message": "Rate Limit Exceeded"
}
}

I checked this documentation but it doesn't help me https://developers.google.com/calendar/api/guides/batch

Also, checked some StackOverflow and followed its solution but it's can not help me. I tried code similar to this but it's won't work

    $client->setUseBatch(true);
    $batch = $service->createBatch();
    $query = 'Henry David Thoreau';
    $optParams = array('filter' => 'free-ebooks');
    $req1 = $service->volumes->listVolumes($query, $optParams);
    $batch->add($req1, "thoreau");
    $query = 'George Bernard Shaw';
    $req2 = $service->volumes->listVolumes($query, $optParams);
    $batch->add($req2, "shaw");
    
    $results = $batch->execute();

Below are references I already tried

Compo
  • 36,585
  • 5
  • 27
  • 39
Raj Sf
  • 1,408
  • 1
  • 17
  • 26
  • Usage rate limit is flood protection error message. Batching has a habit of causing flooding. There is no way to prevent this you just need to try the request again. Just be careful if you flood to much you will be blocked for the rest of the day. This is why n personally never bother with batching – Linda Lawton - DaImTo Sep 23 '21 at 12:47
  • Have you checked on [Manage quotas](https://developers.google.com/calendar/api/guides/quota) / Use exponential backoff to see the actual limits you are hitting and how to avoid them? Also, can you share your code without personal information to see ho you have it in order to help with the batch request? – Kessy Sep 24 '21 at 08:05

1 Answers1

0

I think changing the code for making batch instance like below works.

$batch = new \Google_Http_Batch($client, false, "https://www.googleapis.com", "batch/calendar/v3/");