question

StevenLiekens-6438 avatar image
0 Votes"
StevenLiekens-6438 asked saldana-msft edited

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

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-users
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JosephXu-MSFT avatar image
0 Votes"
JosephXu-MSFT answered JosephXu-MSFT commented

Hi @StevenLiekens-6438 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




image.png (57.8 KiB)
image.png (85.3 KiB)
image.png (48.7 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Joseph, I just checked the portal (Home > Azure AD > Users > Problem User) and the user does
have a profile picture, so I don't think that's it. I should mention that it works for some users but not for others, without rhyme or reason. All users are provisioned the same way in my company.

0 Votes 0 ·

Ok, @StevenLiekens-6438 let me explore the cause of the problem. But I want to clarify that what the beta version returns is not the user’s Profile Picture.

1 Vote 1 ·