Cannot find a user's photos using Microsoft Graph version 1.0, only beta works

Steven Liekens 1 Reputation point
2021-08-18T15:56:25.987+00:00

Hi, I have some problematic users in my Azure AD tenant where the photos cannot be found if I use a URL like this:

GET https://graph.microsoft.com/v1.0/users/problem.user@contoso.com/photos

Returns

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('problem.user%40contoso.com')/photos",,
  "value": []
}

Surprisingly, it does work when I replace v1.0 with beta in my original request.

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#users('problem.user%40contoso.com')/photos",,
    "value": [
        {
            "@odata.mediaContentType": "image/jpeg",
            "@odata.mediaEtag": "W/\"40fa783936f0fa14b9531bf86702568a0c99cba130fe6d11dc541cbbb0c8cbea\"",
            "id": "48x48",
            "height": 48,
            "width": 48
        },
        {
            "@odata.mediaContentType": "image/jpeg",
            "@odata.mediaEtag": "W/\"40fa783936f0fa14b9531bf86702568a0c99cba130fe6d11dc541cbbb0c8cbea\"",
            "id": "64x64",
            "height": 64,
            "width": 64
        },
        {
            "@odata.mediaContentType": "image/jpeg",
            "@odata.mediaEtag": "W/\"40fa783936f0fa14b9531bf86702568a0c99cba130fe6d11dc541cbbb0c8cbea\"",
            "id": "96x96",
            "height": 96,
            "width": 96
        },
        {
            "@odata.mediaContentType": "image/jpeg",
            "@odata.mediaEtag": "W/\"40fa783936f0fa14b9531bf86702568a0c99cba130fe6d11dc541cbbb0c8cbea\"",
            "id": "120x120",
            "height": 120,
            "width": 120
        },
        {
            "@odata.mediaContentType": "image/jpeg",
            "@odata.mediaEtag": "W/\"40fa783936f0fa14b9531bf86702568a0c99cba130fe6d11dc541cbbb0c8cbea\"",
            "id": "240x240",
            "height": 240,
            "width": 240
        },
        {
            "@odata.mediaContentType": "image/jpeg",
            "@odata.mediaEtag": "W/\"40fa783936f0fa14b9531bf86702568a0c99cba130fe6d11dc541cbbb0c8cbea\"",
            "id": "360x360",
            "height": 360,
            "width": 360
        },
        {
            "@odata.mediaContentType": "image/jpeg",
            "@odata.mediaEtag": "W/\"40fa783936f0fa14b9531bf86702568a0c99cba130fe6d11dc541cbbb0c8cbea\"",
            "id": "432x432",
            "height": 432,
            "width": 432
        },
        {
            "@odata.mediaContentType": "image/jpeg",
            "@odata.mediaEtag": "W/\"40fa783936f0fa14b9531bf86702568a0c99cba130fe6d11dc541cbbb0c8cbea\"",
            "id": "504x504",
            "height": 504,
            "width": 504
        },
        {
            "@odata.mediaContentType": "image/jpeg",
            "@odata.mediaEtag": "W/\"40fa783936f0fa14b9531bf86702568a0c99cba130fe6d11dc541cbbb0c8cbea\"",
            "id": "648x648",
            "height": 648,
            "width": 648
        }
    ]
}

I found this related issue on Stack Overflow but no real solution. I'd rather not use the beta version if at all possible.
https://stackoverflow.com/questions/56851425/not-able-to-get-photo-using-microsoft-graph-api

Thanks

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,669 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JosephXu-MSFT 531 Reputation points
    2021-08-19T02:25:44.483+00:00

    Hi @Steven Liekens this problem seems to be caused by your user not having an Profile Picture. Also the Beta endpoint response enumerates all supported HD photo sizes on Microsoft 365(48x48, 64x64, 96x96, 120x120, 240x240, 360x360, 432x432, 504x504, and 648x648) instead of the user's Profile Picture.

    1. The issue on Stack Overflow response an error, but yours is an empty array. It means the user doesn't have any Profile Picture. Make sure you have upload user photo in azure portal profile. When the user has Profile Picture , we will get the picture's metadata from this endpoint https://graph.microsoft.com/v1.0/users/problem.user@contoso.com/photos.
      124493-image.png
    2. According to this beta reference documentation. When we call this beta version endpoint https://graph.microsoft.com/beta/users/problem.user@contoso.com/photos, this endpoint will response enumerate all supported sizes of HD photos on Microsoft 365.
      124400-image.png
    3. The issue on Stack Overflow is using different endpoint https://graph.microsoft.com/v1.0/users/{id | userPrincipalName}/photo/$value). This endpoint will response the picture itself instead of the picture's metadata.
      124502-image.png