I want to add extensions to a User using GraphClient. I couldn't find the proper C# code anywhere. Can anyone help?
Dictionary<string, object> addData = new Dictionary<string, object> {
{
"HoloFlag",
currentUser.UserPrincipalName
}
};
var extPatchObject = new OpenTypeExtension();
extPatchObject.ExtensionName = "com.holobeam3.extension";
extPatchObject.AdditionalData = addData;
try {
var extension = await _graphClient
.Me
.Extensions
.Request()
.AddAsync(extPatchObject);
Debug.Log(extension);
} catch (Exception ex) {
Debug.Log(ex.Message);
}
This is what I tried so far. This returns an "access denied" exception but there is no issue in accessing existing extensions or other Me
endpoints of the User.
In order to add a new extension follow this code:
_graphClient = new GraphServiceClient(new DelegateAuthenticationProvider(async requestMessage =>
{
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken);
}));
Dictionary<string, object> addData = new Dictionary<string, object>
{
{"Key","Value" }
};
var extObject = new OpenTypeExtension();
extObject.ExtensionName = "TestExtension";
extObject.AdditionalData = addData;
try
{
await _graphClient.Users["usernamegoeshere"].Extensions.Request().AddAsync(extObject);
}
In order to fetch an extension follow this code:
var userExtensions = await _graphClient.Me.Extensions["nameofExtension"].Request().GetAsync();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With