Microsoft Graph - Not able to assign manager to a user

Dennis Wetterlund 11 Reputation points
2022-07-06T05:55:28.387+00:00

Hi,

Im having issues when trying to assign a user as a manger to a another user.

Here is my solution:

 private async Task<GraphResponse> UpdateUserWithManagerAsync(GraphServiceClient client, AdUser user, AdUser manager)  
  {  
               
  
         user.Id = 0e2f61df-780a-42b1-8f53-9e32da2a4dba;  
         manager.Id = 2d0b68a9-3e6d-47ac-951c-eb7b985ee9a0;  
   
        return await client.Users[user.Id].Manager.Reference.Request().PutResponseAsync(manager.Id);  
  
 }  

The request returns a 204 - No Content but I can´t see that the user has a manager assigned.

Microsoft Security | Microsoft Graph
Developer technologies | C#
Developer technologies | C#

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.

0 comments No comments

2 answers

Sort by: Oldest
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Dennis Wetterlund 11 Reputation points
    2022-07-06T08:56:17.147+00:00

    Hi @CarlZhao-MSFT ,

    I discovered one difference betweeen your solution and mine and that was that I forget to to pass the variable options to ClientSecretCredential. I also did not have the request to GET:/users/{user-id}/manager but I added it and now I can see that the user has a manager assigned to it, before I just made a request to get the user and saw that the manager property on the user object was null in the response.

    Thank you!

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.