Getting error while trying to fetch user profile image using graph ai

Poonam Navapara 0 Reputation points
2023-12-11T05:30:40.45+00:00

Hello sir,

I want to fetch user profile image using the user id, for that i am calling this api

URL: https://graph.microsoft.com/beta/users/7147347d-4ea1-4f21-9cc7-b50415e781e1/photo/$value

Resposne:

{
    "error": {
        "code": "UnknownError",
        "message": "",
        "innerError": {
            "date": "2023-12-11T05:28:58",
            "request-id": "89f2a9c6-a100-422b-afae-268d9349cb09",
            "client-request-id": "89f2a9c6-a100-422b-afae-268d9349cb09"
        }
    }
}

can you check why i am getting this error please thank you.

I also want to fetch website_url and user metadata, can you tell me how that is possible?

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

1 answer

Sort by: Most helpful
  1. Carolyne-3676 201 Reputation points
    2024-03-07T13:02:04.65+00:00

    A couple of things to look out for:

    1. Permissions: Ensure you have the right permissions to access user profile photos. For Delegated Permissions it is User.Read and for Appication Permissions, the least required is User.Read.All- (Documentation)

    2.User photo: Make sure the user has a profile photo set. If the user does not have a profile photo, the API call will return an error.

    1. User Metadata: You can use the $select statement to view specific metadata. Metadata is not supported for Personal Microsoft Accounts as stated in the documentation.
    2. Version: Try and also run this request on Graph Explorer and see if the issue persists. You can also check your permissions on Graph Explorer. You can also run in V1 since this is available in V1.
    0 comments No comments