MS Graph API 中的分页 [英] Paging in MS Graph API

查看:27
本文介绍了MS Graph API 中的分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Graph API Paging 解释说响应将包含一个字段 @odata.nextLink 将包含一个指向下一页内容的 skiptoken.

Graph API Paging explains that the response would contain a field @odata.nextLink which would contain a skiptoken pointing to the next page of contents.

当我测试 API 时,我得到了一个完全限定的 MS Graph URL,其中包含 skiptoken 作为查询参数.例如.以下是我为响应 JSON 中的字段 @odata.nextLink 获得的值.<代码> https://graph.microsoft.com/v1.0/users?$top=25&$skiptoken=X%27445370740200001E3A757365723134406F33363561702E6F6E6D6963726F736F66742E636F6D29557365725F31363064343831382D343162382D343961372D383063642D653136636561303437343437001E3A7573657235407368616C696E692D746573742E31626F74322E696E666F29557365725F62666639356437612D333764632D343266652D386335632D373639616534303233396166B900000000000000000000%27

When I test the API, I'm getting a fully-qualified MS Graph URL which contains the skiptoken as a query param. E.g. Below is the value I got for the field @odata.nextLink in the response JSON. https://graph.microsoft.com/v1.0/users?$top=25&$skiptoken=X%27445370740200001E3A757365723134406F33363561702E6F6E6D6963726F736F66742E636F6D29557365725F31363064343831382D343162382D343961372D383063642D653136636561303437343437001E3A7573657235407368616C696E692D746573742E31626F74322E696E666F29557365725F62666639356437612D333764632D343266652D386335632D373639616534303233396166B900000000000000000000%27

是否可以假设我们将始终获得完整的 URL 而不仅仅是 skiptoken?因为如果它是真的,它有助于避免解析 skiptoken 然后将其连接到现有的 URL 以自己形成完整的 URL.

Is it safe to assume we'll always get the full URL and not just the skiptoken? Because if it's true, it helps avoid parsing the skiptoken and then concatenating it to the existing URL to form the full URL ourselves.

EDIT - 与 MS Graph API 相比,从 Azure AD Graph API 获得的响应不同之处在于 JSON 字段 @odata.nextLink 仅包含 skipToken 而不是完全限定的 URL.

EDIT - Compared to MS Graph API, response obtained from Azure AD Graph API differs in that the JSON field @odata.nextLink contains only the skipToken and not the fully-qualified URL.

推荐答案

是的.在 Microsoft Graph 中,您可以假设您将始终获得 @odata.nextLink 的完全限定 URL.您可以简单地使用下一个链接来获取下一页结果,并且客户端应该将 nextLink 视为不透明的(在 OData v4 和 Microsoft REST API 指南中都有描述:https://github.com/Microsoft/api-guidelines/blob/master/Guidelines.md#98-分页.
这与 AAD Graph API(不是 OData v4)不同,后者不返回完全限定的下一个链接,这意味着您需要进行一些更复杂的操作才能获得下一页结果.

Yes. In Microsoft Graph you can assume that you'll always get the fully qualified URL for the @odata.nextLink. You can simply use the next link to get the next page of results, and clients should treat the nextLink as opaque (which is described in both OData v4 and in the Microsoft REST API guidelines here: https://github.com/Microsoft/api-guidelines/blob/master/Guidelines.md#98-pagination.
This is different from AAD Graph API (which is not OData v4), which doesn't return the fully qualified next link, and means you need to do some more complicated manipulations to get the next page of results.

因此,Microsoft Graph 应该为您简化这一过程.

Hence Microsoft Graph should make this simpler for you.

希望这会有所帮助,

这篇关于MS Graph API 中的分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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