How to get all users with a specific manager with Graph Client Factory?

Nicolas Duchaine 20 Reputation points

Hi, I'm currently developing an SPFx webapp to fetch all users with a specific userPrincipalName as their manager. However, this is my first time working with GraphAPI, and I feel like my query is a bit wobbly, and I need some help. I feel like something is missing in my query, but I'm not quite sure what it is. Thank you!

      .then((client: MSGraphClientV3) => {
        // From sample
          .filter(`manager/userPrincipalName eq '${escape(this.state.searchForManager)}'`)
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,779 questions
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,793 questions
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous

    Hi @Anonymous ,

    Thanks for reaching out! As per my understanding you are trying to fetch all the users' details who are reporting to specific manager. For this scenario, there is a direct API available which will give you the all the users who has manager specified in the request URL/endpoint.

    Get the reports for the manager userPrincipalName.{managerUserPrincipalName}/directReports

    Document reference:

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

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful