无法使用 GraphServiceClient 更新用户用户、GraphServiceClient

2023-09-06 17:43:20 作者:冷眼看你装i

我的问题正是标题中所说的.如果我想使用 MicrosoftGraph 与用户交互,我有几个选择:

My problem is exactly what it says in the title. If I want to interact with users using MicrosoftGraph, I have a few options:

graphClient.Users.Request.GetAsync()
graphClient.Users.Request.AddAsync()

我想看看:

graphClient.Users.Request.UpdateAsync()

不幸的是,我的问题是我没有看到它.它在哪里?我在其他一些对象上看到了 UpdateAsync……为什么它不在用户身上?我错过了一些重要的文档吗?

Unfortunately, my problem is that I don't see it. Where is it? I see UpdateAsync on a few other objects... why is it not on users? Did I miss some crucial piece of documentation?

推荐答案

它在用户上.你错过了一些东西.您尚未识别用户,请使用索引器.此外,Request 是一种方法,而不是属性.

It is on User. You're missing a few things. You haven't identified the user, use the indexer. Also, Request is a method, not a property.

var betterMe = new User()
{
   GivenName = "Super Man"
};

// Update the user to Super Man
await graphClient.Users[myId].Request().UpdateAsync(betterMe);