PHP SDK - Timeout while getting calendar events

René Burow Sørensen 1 Reputation point
2021-03-29T12:27:30.08+00:00

When sending a request for events for the next 1825 days (max allowed) I get a timeout for 2 authorizations (out of maybe 80 in total). The timeout I get is from Guzzle/cURL

The code i use is the following:

$calendar_id is a valid UUID for a calendar.
$from and $to are DateTime objects.

$events = [];

$query = [
'startDateTime' => $from->format('c'),
'endDateTime' => $to->format('c'),
];

$response = $this->graph->createCollectionRequest('GET', '/me/calendars/'.$calendar_id.'/calendarView?'.http_build_query($query))
->setReturnType(Model\Event::class)
->addHeaders(['Prefer' => 'outlook.timezone="Europe/Copenhagen"'])
->setTimeout(20)
->setPageSize(20);

while(!$response->isEnd()){
$events = array_merge($events, $response->getPage());
}

return $events;

Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Deva-MSFT 2,271 Reputation points Microsoft Employee
    2021-03-30T17:21:18.58+00:00

    When you deal with good number of data in response (as i see that you're trying with max value), i would suggest you to use Microsoft Graph pagination to start with.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.