Microsoft.Fast.Profile.Core.Exception.ImageNotFoundException - Cannot PUT a profile picture via MS Graph

VincentNed 5 Reputation points
2023-02-09T09:36:41.3266667+00:00

I am trying to update a profile picture on behalf of the current logged in user (by Open ID Connect) by using the following MS Graph interfaces:

PUT /me/photo/$value
PUT /users/{id | userPrincipalName}/photo/$value

Regardless of the endpoint I use (/me/ or /users/principalname) or whether I use PUT or PATCH methods, I constantly receive the following error:

{"error":{"code":"InvalidImage",
"message":"Exception of type 'Microsoft.Fast.Profile.Core.Exception.ImageNotFoundException' was thrown.",
"innerError":....}

I have made sure to have delegated User.ReadWrite permissions and in each test case I have succcesfully obtained a token through OIDC. The image I try to upload is a .JPEG image and I Base 64 encoded it's binary content.

PUT https://graph.microsoft.com/v1.0/me/photo/$value
Content-Type: image/jpeg
Authentication: Bearer {token}

[Base 64 encoded binary content of JPEG image]

The error does not make sense to me for a PUT or PATCH method as you would expect no existing image to be required (although I made sure that my user account has a profile picture available). Does anyone have an idea of a possible root cause of this error?

Any help/direction is much appreciated! :)

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

2 answers

Sort by: Most helpful
  1. Richards, Dylan 5 Reputation points
    2023-03-02T13:12:10.4766667+00:00

    Were you ever able to figure this out? I'm currently running into the same issue.

    1 person found this answer helpful.
    0 comments No comments

  2. CharanyaB-MSFT 1,421 Reputation points Microsoft Vendor
    2023-04-07T08:54:16.0333333+00:00

    Hello @VincentNed,

    Thanks for reaching out!

    I have tried this API locally and it is working fine. The profile photo is updated successfully. Please pass the valid binary data for the image and try executing the API. If the issue still persists, I recommend you to raise a support case with Microsoft Graph, a Support Engineer will be able to assist you better.

    You can raise support ticket from
    [http://aad.portal.azure.com] or https://admin.microsoft.com/#/support/requests.

    Documentation reference: https://learn.microsoft.com/en-us/graph/api/profilephoto-update?view=graph-rest-1.0&tabs=http#:~:text=User.ReadWrite.All-,Note,-To%20update%20the

    Hope this helps.

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

    0 comments No comments