首页 > 解决方案 > Graph Api 响应中的 nextLink 不是绝对 Uri

问题描述

我们正在调用图形 api 以使用此 url在我们的 Azure B2C AD 中获取用户

https://graph.windows.net/TENANTNAME.onmicrosoft.com/users?api-version=1.6&$top=10&$select=objectId,userType,displayName,signInNames,createdDateTime&$filter=userType%20eq%20'Member'

请注意,在我编写此分页代码时,页面大小故意设置为 10 小

文档说,如果要提取更多数据,则响应中将有一个 nextLink 属性,如果存在,则应该使用 uri 来获取下一页数据。我们确实看到了一个更准确的 nextLink,odata.nextLink但是该值不能用作下一个请求的 uri。

这是一个例子

directoryObjects/$/Microsoft.DirectoryServices.User?$select=objectId,userType,displayName,signInNames,createdDateTime&$filter=userType%20eq%20'Member'&$skiptoken=X'010001000000030000005903BF45BBE7EA4CB7378BD076AD388026EC6A89C7479240A83DE15C99D42A0C4B7E5E4C707FB448B45655AED90920FA6D7126F4D8990'

请注意,skiptoken 值已缩短

我可以解析 nextLink 并为下一页组装一个 uri,但这似乎是一个愚蠢的想法,因为 nextLink 的值对我来说应该是不透明的。

是因为我们调用的是 B2C 租户吗?

是否有解析该链接的商定方法?

标签: azuremicrosoft-graph-apiazure-ad-b2c

解决方案


This is a problem caused by design, Azure AD graph api just provide this kind of nextlink. Actually, Microsoft is recommending to use Microsoft Graph in place of the Azure Active Directory Graph API in order to access Azure AD’s resources. So you can use Microsoft graph api "list users" to get the users in your AD, and it will show the absolute uri for the next link.

enter image description here


推荐阅读