Abdel Matyne
Abdel Matyne

Reputation: 93

Cannot update an B2C local user profile photo on Azure portal/ using Graph with application issued token

I have B2C local accounts and when I'm trying to get/update their profile infos using Graph API with aplication issued token, it worked. But when I try to get/update their profile photo, I get 404 errors.

request: (GET)

https://graph.microsoft.com/v1.0/users/{userOid}/photo

response: 404

{
  "error": {
    "code": "ImageNotFound",

    "message": "Exception of type 'Microsoft.Fast.Profile.Core.Exception.ImageNotFoundException' was thrown.",

    "innerError": {
      "date": "2021-10-26T16:12:52",

      "request-id": "ac24acee-8317-4d77-95ea-c69df189e7cb",

      "client-request-id": "ac24acee-8317-4d77-95ea-c69df189e7cb"
    }
  }
}

request: (PUT/POST) and setting the content type as well

https://graph.microsoft.com/v1.0/users/{userOid}/photo/$value

response: 404

{
  "error": {
    "code": "UnknownError",

    "message": "{\r\n \"errorCode\": \"ErrorUserResolutionFailedUserDoesNotExist\",\r\n \"message\": \"Exception of type 'Microsoft.Fast.Profile.Core.Exception.ProfileNotFoundException' was thrown.\",\r\n \"target\": null,\r\n \"details\": null,\r\n \"innerError\": null,\r\n \"instanceAnnotations\": []\r\n}",

    "innerError": {
      "date": "2021-10-26T16:13:55",

      "request-id": "3517b374-a08d-41a1-8f68-9c9da3cbfb3b",

      "client-request-id": "3517b374-a08d-41a1-8f68-9c9da3cbfb3b"
    }
  }
}

Upvotes: 0

Views: 911

Answers (1)

RamaraoAdapa
RamaraoAdapa

Reputation: 3119

Currently, you are using Microsoft Graph REST API V1.0 to get/update user photo for B2C local accounts.

But these operation in version 1.0 supports only a user's work or school mailboxes and not personal mailboxes

So you can use Microsoft Graph REST API beta version to get/update user photo for B2C local accounts.

When getting / updating the user photo using beta version, this operation first attempts to get / update the photo in Microsoft 365. If that fails (due to the user not having a mailbox), this API will attempt to get / update the photo in Azure Active Directory

Note : For updating profile photo for users, use only PUT operation.

For getting the profile photo of user, please make sure the user has profile photo in the Azure AD. Else, it will throw ImageNotFound error.

Reference :

profilePhoto resource type - Microsoft Graph beta | Microsoft Docs

profilePhoto resource type - Microsoft Graph v1.0 | Microsoft Docs

Upvotes: 0

Related Questions