Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.2k views
in Technique[技术] by (71.8m points)

azure - Not able to get photo using Microsoft graph 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:

enter image description here

Post Man Request Example:

Request URL:

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

![enter image description here

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...