Microsoft Graph API > setting manager property not working

Steven Kang 1 Reputation point

I am using MS Graph API to update the user's manager using a C# console application. This was working until a few days ago. It no longer seems to work. I am not getting any errors.

As a test, I used PowerShell to set the manager --> "Set-MgUserManagerByRef". This works fine.

Did something change?


Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,875 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,402 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 37,871 Reputation points

    Hi @Steven Kang

    Nothing seems to have changed, I just used a C# console application to assign managers to employees and it works fine. Refer to my code:

    using Azure.Identity;  
    using Microsoft.Graph;  
    var scopes = new[] { "" };      
    var tenantId = "tenant id";  
    var clientId = "client id";  
    var clientSecret = "client secret";  
    // using Azure.Identity;  
    var options = new TokenCredentialOptions  
        AuthorityHost = AzureAuthorityHosts.AzurePublicCloud  
    var clientSecretCredential = new ClientSecretCredential(  
     tenantId, clientId, clientSecret, options);  
    var graphClient = new GraphServiceClient(clientSecretCredential, scopes);  
    await graphClient.Users["employee id"].Manager.Reference  
     .PutAsync("manager id");  

    Note that you can only assign managers to employees and cannot assign direct reports to managers.

    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.