dongpou1935 2019-06-08 08:56
浏览 234
已采纳

如何使用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 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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 怎么获取下面的: glove_word2id.json和 glove_numpy.npy 这两个文件
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug