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

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

问题描述

图形API分页解释了该响应将包含一个字段@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.

编辑-与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指南中都进行了描述:

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天全站免登陆