有人可以給我一個提示如何使用Microsoft Graph .NET Client Library來設置User.Manager字段嗎?我知道how to do this via a direct REST call,但希望儘可能避免這些調用(繞過包裝器)。通過下面的代碼,我可以清除管理器屬性。使用Microsoft Graph .NET客戶端庫指定管理器
client = new GraphClient(...);
var builder = new DirectoryObjectWithReferenceRequestBuilder(
client.Users["<userid>"].Manager.Request().RequestUrl,client
);
builder.Request().DeleteAsync().Wait()
然而,我仍然無法找出哪些類允許我建立爲成員參考(as described here)PUT請求。我嘗試了以下代碼:
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();
此代碼不會引發異常,但它也不會更新管理器。請求是錯誤的。上面的代碼將一個PATCH而不是一個PUT發送到「基本」對象。通過上面的代碼生成
請求:
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]"}
響應是一個204
看起來這可能是在圖書館的空白。感謝您指出了這一點。讓我檢查並回復你。 –