I'm trying to update the description for an existing group in Azure AD, but I'm getting an error message that I'm not sure how to resolve.
public static async Task<bool> UpdateGroup(GraphServiceClient graphClient, Group group)
{
// Update the group.
Group grp = await graphClient.Groups[group.Id].Request().GetAsync();
grp.Description = group.Description;
await graphClient.Groups[group.Id].Request().UpdateAsync(grp);
return true;
}
The above just throws an exception:
Code: BadRequest Message: Operation not supported.
I'm not sure if this is a lack of enabled permissions for the API in Azure or if updating a group genuinely isn't supported? I can Create/Delete groups easily enough, so surely updating an existing group should be just as easy?
Your problem is that you're first populating grp
, changing a single property, and then attempting to PATCH
the entire Group object. So along with your updated description, you're also attempting to PATCH
(and this is where the error comes from) several read-only properties (e.g. id
).
Your code should look like this:
await graphClient
.Groups[group.Id]
.Request()
.UpdateAsync(new Group() {
Description = group.Description
});