GET team member detail with their profile image

Ayan Usmani 151 Reputation points
2022-09-02T06:43:25.857+00:00

I have a use case to fetch team member's details (i.e reporting to specific manager) along with their profile image.

Is there any API already that can be used ?

If not, kindly suggest a way to tackle this use case .

Note :- I am aware about the /directReports API , but it doesn't sends user profile image url in response

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

2 answers

Sort by: Most helpful
  1. Srinivasa Rao Darna 6,686 Reputation points Microsoft Vendor
    2022-09-02T10:56:10.657+00:00

    Hi @Ayan Usmani ,

    Upon on my test, you cannot get photos of directreports with a single Graph API request.

    Step1: Get people reporting to a manager using Get /users/{user-id}/directReports

    GET /users/{user-id}/directReports  
    Content-type: application/json  
    =========  
    {  
        "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#directoryObjects",  
        "value": [  
            {  
                "@odata.type": "#microsoft.graph.user",  
                "id": "6ea91a8d-e32e-41a1-b7bd-d2d185eed0e0",  
                "businessPhones": [],  
                "displayName": "Conf Room Adams",  
                "givenName": null,  
                "jobTitle": null,  
                "mail": "Adams@Contoso.OnMicrosoft.com",  
                "mobilePhone": null,  
                "officeLocation": null,  
                "preferredLanguage": null,  
                "surname": null,  
                "userPrincipalName": "Adams@Contoso.OnMicrosoft.com"  
            }  
        ]  
    }  
    

    Step2: From the Graph response collection use the properties like id or userPrincipalName to get photos of the users returned in step1.
    You may have to write code to loop through all the responses retuned in step1.

    GET /users/{id | userPrincipalName}/photo/$value  
    

    Hope this helps.
    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".


  2. Zehui Yao_MSFT 5,826 Reputation points
    2022-09-27T02:49:41.953+00:00

    Hi @Ayan Usmani , please try using the microsoft Graph toolkit as it completes the relevant request as a component and can display the results directly on the page.
    And here is the person component for your reference: https://learn.microsoft.com/en-us/graph/toolkit/components/person?view=graph-rest-1.0
    Hope this helps. I wish you all the best.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.