I'm trying to get User Mailbox Settings from Microsoft Graph v1.0 with the Ms Graph .Net SDK and with application permissions.
I have the correct permissions (MailboxSettings.Read and User.Read.All) and they are admin consented.
Here is the code for the call:
var settings = await graphClient.Users[{userId}].Request()
.Select(e => new
{
e.MailboxSettings
})
.GetAsync();
When I make the call I get the error:
ErrorAccessDenied, Access is denied. Check credentials and try again.
There is (probably) nothing wrong with my graphClient object as I can successfully call other resources, for instance:
var events = await graphClient.Users[{userId}].Events.Request()
I have tried to make a HTTP request to the API and then I get a successful response. (I'm using the same clientId, clientSecret etc. when I create the graphClient and when I fetch the auth token for the API call).
This is the endpoint I'm calling:
https://graph.microsoft.com/v1.0/users/{userId}/mailboxSettings
Why do I get an error when I use the SDK? Is my request incorrect or is there a bug in the SDK?