I am using microsoft-graph api sdk here is the url: msgraph-sdk-php
I need to check if an user's appointment is available / busy in the outlook calendar.
I am trying using following code
$graph = new Graph();
$graph->setAccessToken($this->getToken($calendar));
$data = [
'Schedules' => 'useremail@gmail.com',
'Start' => [
'DateTime' => '2019-06-8T09:00:00+0530',
'TimeZone' => 'Pacific Standard Time',
],
'End' => [
'DateTime' => '2019-06-9T09:00:00+0530',
'TimeZone' => 'Pacific Standard Time',
],
'availabilityViewInterval' => '30',
];
$url = "/me/calendar/getschedule";
$response = $graph->createRequest("POST", $url)
->attachBody($data)
->setReturnType(Model\ScheduleItem::class)
->execute();
I am getting following error : message: "Client error: POST https://graph.microsoft.com/v1.0/me/calendar/getschedule
resulted in a 400 Bad Request
response:↵{
↵ "error": {
↵ "code": "RequestBodyRead",
↵ "message": "When trying to read a null collection parameter value i (truncated...)↵
I have also checked this microsoft docs details here is the url : outlook-get-free-busy-schedule
I did not found getschedule-api using php microsoft-graph sdk in documentation. I need to use php microsoft-graph api sdk.
kindly provide me any solution about this error.
Thanks.
We do not need to pass
setReturnType
Try using this :
$data = [
'Schedules' => ['avniphadkar@gmail.com'],
"StartTime" => (object)[
"dateTime" => "2019-06-08T09:00:00",
"timeZone" => "Pacific Standard Time"
],
"EndTime" => (object)[
"dateTime" => "2019-06-8T23:00:00",
"timeZone" => "Pacific Standard Time"
],
'availabilityViewInterval' => '30'
];
$url = "/me/calendar/getschedule";
$response = $graph->createRequest("POST", $url)
->attachBody($data)
->execute();
print_r($response)
;
Hope this'll help.