2-bits
2-bits

Reputation: 473

Can't Update Users with GraphServiceClient

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()

I would like to see:

graphClient.Users.Request.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?

Upvotes: 5

Views: 4088

Answers (2)

MalithaRukshan
MalithaRukshan

Reputation: 31

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

await graphClient.Users["{user-id}"].PatchAsync(betterMe);

Upvotes: 3

Michael Mainer
Michael Mainer

Reputation: 3465

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);

Upvotes: 8

Related Questions