gpt4 book ai didi

microsoft-graph-api - Microsoft Graph API 不遵守 OData

转载 作者:行者123 更新时间:2023-12-04 14:53:54 26 4
gpt4 key购买 nike

我正在尝试将所有用户拉入特定组并获得他们的传递成员资格。

我到达的终点是:

https://graph.microsoft.com/v1.0/groups/{id}/transitiveMembers/microsoft.graph.user?$select=givenName,surname,country,city,companyName,officeLocation,displayName,mail,department,jobTitle,employeeId&$expand=transitiveMemberOf

这会拉取我需要的数据,但返回的负载中有一个 OData 类型 microsoft.graph.group 的对象导致以下错误:

A resource of type 'microsoft.graph.group' was found in a resource set that otherwise has entries of type 'microsoft.graph.user'. In OData, all entries in a resource set must have a common base type.

这会导致 unexpected token 的 JSON 解析错误。响应确实包含下一个链接,我希望能够处理此错误并转到下一页。但是,JSON::ParserError 阻止我这样做。

当在请求 url 中指定 microsoft.graph.user 时,有什么可能导致返回 microsoft.graph.group 对象的想法吗?

最佳答案

我的解决方案是添加 $count=true 查询参数并设置 ConsistencyLevel header 。这使得错误消失并且调用成功。

它甚至在文档中这样说:

enter image description here

糟糕。在撰写本文时, header 和查询参数都是必需的。

关于microsoft-graph-api - Microsoft Graph API 不遵守 OData,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68510538/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com