Jake Bauer Jake Bauer - 4 months ago 17
C# Question

How update extensions using Microsoft Graph Client

I have been trying to update extensions via the Microsoft Graph Client. I have figured out how to add extensions using:

Dictionary<string, object> addData = new Dictionary<string, object>();
addData.Add("test", "data");
var ext = new OpenTypeExtension();
ext.ExtensionName = "TestData";
ext.AdditionalData = addData;
try
{
graphClient.Users["usernameGoesHere"].Extensions.Request().AddAsync(ext).Wait();
}


But there appears to be a distinct lack of an update async call available under request. I am wondering if I am missing something. I am using Graph Client version Microsoft.Graph 1.4 and Microsoft.Graph.Core 1.5.

Answer Source

Yes, you are missing one small detail. You have to provide the extension identifier to get the correct request builder for updating an extension.

Dictionary<string, object> addData = new Dictionary<string, object>();
addData.Add("testUpdateKey", "dataUpdateValue");
var extPatchObject = new OpenTypeExtension();
extPatchObject.ExtensionName = "TestData";
extPatchObject.AdditionalData = addData;
try
{
    graphClient.Users["usernameGoesHere"].Extensions["TestData"].Request().UpdateAsync(extPatchObject).Wait();
}