dongpou1935
2019-06-08 08:56 阅读 168
已采纳

如何使用microsoft-graph sdk php获取Outlook免费繁忙日程

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.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    duanchong3075 duanchong3075 2019-06-08 10:14

    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.

    点赞 评论 复制链接分享

相关推荐