Microsoft Graph NextLink 不工作

Microsoft Graph NextLink Not Working

我在使用 server-side 分页时遇到问题,根据 this page 中的信息,利用 @odata.nextlink 从 Microsoft Graph 获取下一页数据。我使用的是原始 GET,在 header 中设置了授权令牌(即,我没有使用语言 API,我正在使用 curl 从 Powershell 尝试此操作)。我已经从以下片段中删除了敏感数据,用 x 替换它们,但希望能找到有问题的信息。

对于第一个 GET,我使用

进行查询
https://graph.microsoft.com/beta/drives/b!Gxxxxx-xxxxxxge/root:/ReallyBigFolder:/children?top=200

我收到了 200 项的回复,正如预期的那样。此响应中的 @odata.nextlink 字段是

https://graph.microsoft.com/beta/drives/b!Gxxxxx-xxxxxxge/root/children?top=200&$skiptoken=Paged%3dTRUE%26p_SortBehavior%3d0%26p_FileLeafRef%3d279%252ezip%26p_ID%3d208%26p_FileDirRef%3dMaintenance%2520Department%252fReallyBigFolder%26RootFolder%3dMaintenance%2520Department%252fReallyBigFolder

对于上面链接的 Microsoft Graph 文档中的示例,$skiptoken=... 部分有 random-looking 个数字,但我的有 $skiptoken=Paged=TRUE&etc 个。也许 API 自文档编写以来更改了响应,或者我的响应完全不正确。

我对文档的理解是,我应该能够将此 URL 用作不透明值,并从图形 API 中获取它(当然使用身份验证令牌)而无需修改。但是,当我这样做时,响应是

{"@odata.context":"https://graph.microsoft.com/beta/$metadata#drives('b%21Gxxxxx-xxxxxxge')/root/children","value":[]}

在我期望列出另外 200 个文件的地方,根本没有返回任何文件,而且路径似乎已经消失,指向根目录而不是应该指向的子文件夹。

我也在 Graph Explorer 中用 /beta/v1.0 端点尝试过这个,但它也以同样的方式失败了。

我哪里错了?

使用详细信息进行调试:注意:Graph Explorer 似乎不显示 headers 中的 Date 字段,所以我使用的是 Postman Chrome 这些值的插件。

第一个 GET 请求是

beta/drives/b!xxx-xxxge/root:/Really%20Big%20Folder/ReallyBigFolder:/children

有响应headers

Cache-Control →private
Content-Encoding →gzip
Content-Type →application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Date →Fri, 26 May 2017 19:07:54 GMT
Duration →2033.3889
OData-Version →4.0
Transfer-Encoding →chunked
Vary →Accept-Encoding
client-request-id →6faf5d1d-a291-410a-b269-f4667187d7cb
request-id →6faf5d1d-a291-410a-b269-f4667187d7cb
x-ms-ags-diagnostic →{"ServerInfo":{"DataCenter":"North Central US","Slice":"SliceB","ScaleUnit":"002","Host":"AGSFE_IN_11","ADSiteName":"CHI"}}

和 nextLink(为安全起见略微混淆)

https://graph.microsoft.com/beta/drives/b!xxx-xxxge/root/children?$skiptoken=Paged%3dTRUE%26p_SortBehavior%3d0%26p_FileLeafRef%3d279%252ezip%26p_ID%3d208%26p_FileDirRef%3dGSH%2520Test%252fMaintenance%2520Department%252fReally%2520Big%2520Folder%252fReallyBigFolder%26RootFolder%3d%252fGSH%2520Test%252fMaintenance%2520Department%252fReally%2520Big%2520Folder%252fReallyBigFolder

nextLink 生成 headers(未更改 headers,省略):

Date →Fri, 26 May 2017 19:15:17 GMT
Duration →512.9537
client-request-id →6ba61712-a423-4bc8-9376-cc62bf854329
request-id →6ba61712-a423-4bc8-9376-cc62bf854329
x-ms-ags-diagnostic →{"ServerInfo":{"DataCenter":"North Central US","Slice":"SliceA","ScaleUnit":"001","Host":"AGSFE_IN_7","ADSiteName":"CHI"}}

和结果 body:

{
  "@odata.context": "https://graph.microsoft.com/beta/$metadata#drives('b%21xxxx-xxxxge')/root/children",
  "value": []
}

您是正确的,nextLink 应该是不透明的 URL,returns 您是下一组结果。该字符串的格式可能会随着时间而改变,因此您不应尝试解析或以其他方式解释该字符串,但用法应该相同。

您返回的响应与空结果一致 -- 这意味着没有要列出的其他文件。

您在 ReallyBigFolder 中有多少结果?如果您将 top 设置为不同的值(例如,5?1000?)会发生什么?

请注意,@odata.context描述的是结果,但不一定与请求URL相同。您从 nextLink 返回的 @odata.context 是否与您从初始请求返回的不同?应该是一样的...