首页 > 解决方案 > 分块调用 Microsoft Graph 日历时出现 504 网关超时

问题描述

当我使用 Postman 时,它可以完美运行。但是,如果我在 PHP 中使用相同的标头,则会出现504 Gateway Time-out错误。

这就是我调用请求的方式:

$headers = [
    'Authorization' => 'Bearer ' . $this->getAccessToken(),
    'Cache-Control' => 'private',
    'Transfer-Encoding' => 'chunked',
    'Content-Type' => 'application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8',
    'Content-Encoding' => 'gzip',
    'Vary' => 'Accept-Encoding',
    'x-ms-ags-diagnostic' => '{"ServerInfo":{"DataCenter":"West Europe","Slice":"SliceC","Ring":"5","ScaleUnit":"003","RoleInstance":"AGSFE_IN_12","ADSiteName":"WEU"}}',
    'Preference-Applied' => 'odata.track-changes',
    'OData-Version' => '4.0'
];

$request = $this->guzzle->get('v1.0/me/calendarview/delta?startdatetime=2019-12-12T00:00:00Z&enddatetime=2019-12-13T00:00:00Z', ['headers' => $headers]);
print_r($request->getBody());

一旦我更改Transfer-Encodingchunked(就像在 Postman 中一样),我就会收到网关错误。如果我不使用它,我就不会得到日历事件。

标签: phpmicrosoft-graph-apiguzzlemicrosoft-graph-calendar

解决方案


我认为这与odata.streaming=true;IEEE754Compatible=false;内容类型标题中的有关。通过此标头,您可以告诉 Microsoft 您希望保持连接打开并接收其他更改。(我什至不知道他们支持。)

根据文档,您不需要发送这些额外的标头。


推荐阅读