无法使用 Microsoft 图形 API 获取照片 [英] Not able to get photo using Microsoft graph API

查看:8
本文介绍了无法使用 Microsoft 图形 API 获取照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在将 Microsoft Azure AD 与我们的应用程序集成.我正在尝试使用 Microsoft Graph API (

邮递员请求示例:

请求网址:

https://graph.microsoft.com/beta/users/UserIdOrPrincipalName/photo/$value

要记住的要点:

<块引用>

确保您已在 azure 门户配置文件中上传用户照片.

注意:

<块引用>

Microsoft Graph 中/beta 版本下的 API 可能会发生变化.不支持在生产应用程序中使用这些 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.

Response:

{

    "error": {

        "code": "ResourceNotFound",

        "message": "Resource could not be discovered.",

        "innerError": {

            "request-id": "dc27c602-5734-4dec-9b2a-8b42d5577073",

            "date": "2019-07-02T10:33:42"

        }

    }

}

Thanks

解决方案

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 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

Your Case:

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 Profile Picture:

Post Man Request Example:

Request URL:

https://graph.microsoft.com/beta/users/UserIdOrPrincipalName/photo/$value

Points To Remember:

Make sure you have upload user photo in azure portal profile.

Note:

APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported

这篇关于无法使用 Microsoft 图形 API 获取照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆