Office 365 API - 请求返回HTTP错误400 [英] Office 365 API - Request returned HTTP error 400

查看:158
本文介绍了Office 365 API - 请求返回HTTP错误400的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按照教程从Office 365 API中提取邮件和日历事件。我能够拉邮件但是当我尝试拉日历事件时,我得到了错误400,从谷歌搜索中,显然我的一个标题太长了。我放了一个 var_dump(getallheaders()); ,可以看到以下内容:

I'm trying to follow a tutorial where I pull mail and calendar events from the Office 365 API. I was able to pull mail but when I try to pull calendar events I get back error 400 which, from some Googling, is apparently that one of my headers being too long. I put a var_dump(getallheaders()); and can see the following:

array (size=10)
  'Host' => string 'localhost:9999' (length=14)
  'Connection' => string 'keep-alive' (length=10)
  'Pragma' => string 'no-cache' (length=8)
  'Cache-Control' => string 'no-cache' (length=8)
  'Accept' => string 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' (length=74)
  'Upgrade-Insecure-Requests' => string '1' (length=1)
  'User-Agent' => string 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36' (length=121)
  'Accept-Encoding' => string 'gzip, deflate, sdch' (length=19)
  'Accept-Language' => string 'en-US,en;q=0.8' (length=14)
  'Cookie' => string 'PHPSESSID=286082ac61749c4e351c1218495859bb; SQLiteManager_currentLangue=2' (length=73)

这一切对我来说都很好。我缺少什么?

This all looks fine to me. What am I missing?

编辑 - 当我做 $ response = curl_exec($ curl); 后跟 var_dump($ response); 我明白了:

EDIT - when I do $response = curl_exec($curl); followed by var_dump($response); I get this:

string '{"error":{"code":"RequestBroker-ParseUri","message":"The $orderby expression must evaluate to a single value of primitive type."}}' (length=130)

带有$ orderby表达式的函数是:

The function with $orderby expression is this:

    public static function getEvents($access_token, $user_email) {

        $getEventsParameters = array (
            // Only return Subject, Start, and End fields
            "\$select" => "Subject,Start,End",
            // Sort by Start, oldest first
            "\$orderby" => "Start",
            // Return at most 10 results
            "\$top" => "10"
        );

        $getEventsUrl = self::$outlookApiUrl."/Me/Events?".http_build_query($getEventsParameters);


        return self::makeApiCall($access_token, $user_email, "GET", $getEventsUrl);
    }


推荐答案

好的。问题是我们更改了 Start 属性的类型。它现在是一个复杂的类型。您想要对开始属性的 DateTime 属性进行排序,因此您需要更改此行:

Ok. The issue is that we changed the type for the Start property. It's now a complex type. You want to sort on the DateTime property of the Start property, so you'd want to change this line:

"\$orderby" => "Start",

到此:

"\$orderby" => "Start\DateTime",

我以为我们已经更新了教程,但我看到了PHP一个没有更新。我今天会努力解决这个问题!

I thought we had updated the tutorials, but I see that the PHP one isn't updated. I'll work on getting that fixed today!

这篇关于Office 365 API - 请求返回HTTP错误400的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆