我正在使用 Microsoft Graph API 来获取用户的一些详细信息。我还使用 AD 进行身份验证和授权。
在此应用程序中,用户登录后将搜索某些用户,并需要与搜索匹配的所有用户的一些详细信息。
我使用过滤器点击了下面的users api,但我没有获得有关匹配用户的公司名称的任何详细信息。
https://graph.microsoft.com/v1.0/users?$filter=startswith(displayName,'jo')
以下是相同的回复
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users",
"@odata.nextLink": "https://graph.microsoft.com/v1.0/users?$skiptoken=X%2744537074020001000000203A636F6D7061735F766A61407465737473636F7270696F67726F75702E6E657429557365725F33386664353661362D366361612D343939332D393264642D383439633938613039393033B900000000000000000000%27",
"value": [
{
"businessPhones": [],
"displayName": "John Doe",
"givenName": "John",
"jobTitle": null,
"mail": null,
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": null,
"surname": "Doe",
"userPrincipalName": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d4beb0bbb194b9adb7bbb9a4fabab1a0" rel="noreferrer noopener nofollow">[email protected]</a>",
"id": "c8f63ba1-5150-44c1-b456-468040f12345"
}
]
}
我需要做什么才能为我的组织的用户获取公司名称?
最佳答案
默认情况下,user
资源仅返回属性的子集。根据 documentation :
Note: Getting a user returns a default set of properties only (businessPhones, displayName, givenName, id, jobTitle, mail, mobilePhone, officeLocation, preferredLanguage, surname, userPrincipalName). Use
$select
to get the other properties and relationships for the user object.
换句话说,您需要向查询中添加一个 $select
参数,以列出您想要返回的属性。例如,如果您想检索 id
、userPrincipalName
和 companyName
,您可以使用:
https://graph.microsoft.com/v1.0/users?$select=displayName,id,jobTitle,companyName
完整的可用属性集可以在 User Resource Type 中找到。文档。
关于azure - 微软图形API : get user organization,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55589488/