Need Profile Photo By using Graph API for a list of users by email id

Dixan Thomas 105 Reputation points
2024-02-27T10:53:34.38+00:00

MicrosoftTeams-image

I need to display user Profile Photos in my Website . I have an App registration and added required API Permission for Microsoft Graph to get User Details from Azure AD.

I got user details and I want User Profile photo together.

Steps I had done:

Created a Token API and passed Client credentials in the body to get Bearer token.

Created one more API for getting Profile photo by passing User Email as query parameter and Bearer token in the Header as below:

https://graph.microsoft.com/v1.0/users?$filter=maileq'******@test.com'&$select=id,displayName,userPrincipalName,photo

I'm getting the below response ,It returns only displayName and userPrincipalName:

    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(id,displayName,userPrincipalName,photo)",     "value": [         {             "id": "9679a553-f5fa-4ecf-893e-a6a23d9f46d7",             "displayName": "Test Employee",             "userPrincipalName": "******@test.com"         }     ] }

Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. CarlZhao-MSFT 46,371 Reputation points
    2024-02-28T07:35:26.1666667+00:00

    Hi @Dixan Thomas

    The photo attribute is not a base attribute of the user. To get the user's photo, you need to request the Get profilePhoto API separately.

    GET /users/{id | userPrincipalName}/photo
    

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.