azure-active-directory - Microsoft Graph API - 从 ids 列表中获取目录对象 - 错误请求

标签 azure-active-directory microsoft-graph-api

我需要使用 Microsoft Graph API 获取用户所属的组列表。

为此,我使用端点 POST /users/<userId>/getMemberGroups (doc)。这工作正常,但问题是响应只是组对象 ID 的列表。我也需要获得团体属性。我可以循环遍历列表并查询 GET /groups/<groupId> 的 API但当用户有多个组时,这需要很长时间。

然后我发现POST /directoryObjects/getById ( doc ) 将该列表变成我需要的。我完全按照文档页面进行操作,但出现以下错误:

Request_BadRequest - 请求目标不允许指定的 HTTP 方法。(HTTP 状态 405)

我做错了什么?方法是getById被窃听了?如果是,是否有其他方法可以将组对象 ID 列表转换为组或获取用户组的完整列表?

最佳答案

API Get directory objects from a list of ids你提到应该工作,我在 MS Graph Explorer 中测试它,效果很好。

确保您使用 POST 方法,我可以使用其他方法重现您的问题。

enter image description here

您可以引用以下信息并重试。

请求网址:

POST https://graph.microsoft.com/beta/directoryObjects/getByIds

请求正文:

{
  "ids": [
        "xxxxxxxx-9f1b-4f28-a408-xxxxxxxxxxxx",
        "xxxxxxxx-a614-4335-81eb-xxxxxxxxxxxx",
        "xxxxxxxx-e500-49d6-a705-xxxxxxxxxxxx",
        "xxxxxxxx-5be3-41eb-864d-xxxxxxxxxxxx",
        "xxxxxxxx-961d-4db9-87cf-xxxxxxxxxxxx",
        "xxxxxxxx-93bf-4950-8d96-xxxxxxxxxxxx"
  ],
  "types": [
    "group"
  ]
}

结果:

enter image description here

关于azure-active-directory - Microsoft Graph API - 从 ids 列表中获取目录对象 - 错误请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53274627/

相关文章:

asp.net-mvc - AADSTS70001 : Application with identifier 'guid' was not found in the directory

json - 使用图形 api 在线共享点中创建多项选择字段的 POST 正文是什么?

azure - 微软图: How to look up a user by personal email address?

microsoft-graph-api - 从 SharePoint URL 获取驱动器 ID

c# - 错误 400 - 使用 Microsoft Graph 错误请求创建用户

azure - 为什么 AAD 颁发的访问 token 包含有关用户的信息?

c# - 有没有办法通过控制台应用程序 C# 连接启用 Azure AD MFA 的 Outlook 邮箱?

c# - 使用 Azure Active Directory 的 Blazor Server 聊天应用程序在 Program.cs 中产生异常

office365 - Microsoft Graph API - $search 查询不会对所有结果进行分页

python - Microsoft Graph 身份验证