Can someone give me a hint how to set the User.Manager field using the Microsoft Graph .NET Client Library? I know how to do this via a direct REST call but want to avoid those calls (bypassing the wrapper) as much as possible. With the code below I was able to clear the manager property.
client = new GraphClient(...);
var builder = new DirectoryObjectWithReferenceRequestBuilder(
client.Users["<userid>"].Manager.Request().RequestUrl,client
);
builder.Request().DeleteAsync().Wait()
However, I still can't figure out which class allows me to build a PUT request for the member reference (as described here). I tried to the following code:
var mgr = new DirectoryObject();
mgr.Id = "<Id of the user that should be set as manager>";
var usrPatch = new User();
usrPatch.Manager = mgr;
client.Users["<Id of the user to be updated>"].Request().UpdateAsync(usrPatch).Wait();
This code doesn't throw an exception but it also doesn't update the manager. The request is wrong. The above code sends a PATCH instead of a PUT to the "base" object.
Request generated by the code above:
PATCH https://graph.microsoft.com/v1.0/users/[Id of the user to be updated] HTTP/1.1 SdkVersion: graph-dotnet-1.0.1 Content-Type: application/json Host: graph.microsoft.com Content-Length: 45 Expect: 100-continue {"id":"[Id of the user that should be set as manager]"}
The response is a 204.