无法使用Microsoft graph API获取照片 [英] Not able to get photo using Microsoft graph API
问题描述
我们正在将Microsoft Azure AD与我们的应用程序集成.我正在尝试使用Microsoft Graph API( https://graph.microsoft. com/v1.0/users/ {id | userPrincipalName}/photo/$ value).但是它对我不起作用.我已在应用程序中授予了此API所需的所有权限,但是每次获得响应以下.你能让我错过什么配置吗?
We are integrating Microsoft Azure AD with our application. I am trying to get user profile pic using Microsoft Graph API (https://graph.microsoft.com/v1.0/users/{id | userPrincipalName}/photo/$value) . But its not working for me. I have given all permission required for this API in application but every time getting below response. Can you please let me what configuration I missed.
响应:
{
"error": {
"code": "ResourceNotFound",
"message": "Resource could not be discovered.",
"innerError": {
"request-id": "dc27c602-5734-4dec-9b2a-8b42d5577073",
"date": "2019-07-02T10:33:42"
}
}
}
谢谢
推荐答案
仅当用户拥有邮箱时,才可以读取和更新用户的个人资料照片.此外,以前可能已通过thumbnailPhoto属性(使用Office 365统一API预览,Azure AD Graph或通过AD Connect同步)存储的任何照片将不再通过用户资源的Microsoft Graph照片属性进行访问.有关更多详细信息,您可以在此处的官方文档
Reading and updating a user's profile photo is only possible if the user has a mailbox. Additionally, any photos that may have been previously stored using the thumbnailPhoto property (using the Office 365 unified API preview, or the Azure AD Graph, or through AD Connect synchronization) are no longer accessible through the Microsoft Graph photo property of the user resource. For more details You could check official docs here
Microsoft Graph v1.0从Exchange检索用户的profilePhoto 联机,而不是Azure Active Directory.因此,没有 在Exchange Online中配置的邮箱将没有配置文件照片 可用
Microsoft Graph v1.0 retrieves the user's profilePhoto from Exchange Online, not Azure Active Directory. As such, users that don't have a mailbox provisioned in Exchange Online will not have a profilePhoto available
您的案例:
您可以尝试使用以下格式的Microsoft Graph REST API Beta
版本请求URL:
You could try with Microsoft Graph REST API Beta
version request URL in flowing format:
https://graph.microsoft.com/beta/users/UserIdOrPrincipalName/photo/$value
请参见下面的屏幕截图:
See the screen shot below:
Azure Active Directory配置文件图片:
邮递员请求示例:
请求网址:
https://graph.microsoft.com/beta/users/UserIdOrPrincipalName/photo/$value
要记住的要点:
确保您已在azure门户个人资料中上传用户照片.
Make sure you have upload user photo in azure portal profile.
注意:
Microsoft Graph中/beta版本下的API可能会更改. 不支持在生产应用程序中使用这些API
APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported
这篇关于无法使用Microsoft graph API获取照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!