I am trying to make use of Graph API. On the beginning I was trying to get simply user data, but with below code I was unable: some exception was thrown inside library of async methods (AsyncStateMachineBox::ExecutionContextCallback).
var user = await GetAuthenticatedGraphClient().Me.Request().Select(u => new {
u.DisplayName,
u.Mail,
u.UserPrincipalName
}).GetAsync();
When I sent the same request via cmd and curl I saw response that I don't have permissions. Once they were granted above code started to work. Looks like Graph is responding with an error message and above code didn't check for error but just tries to parse the request to read user's data.
I granted other required permissions and started to make more complicated requests. Sometimes I'm getting the same exception; I think we should be able to read what error the Graph API sends to the application? Surrounding request with try{}catch block didn't catch the exception here (async method?).
How can I know what's wrong with my code, with the request? There is even no data I can provide: what can be helpful for you to help me?
Sending above request from cmd (curl) I can see the response and I know I cannot make this request with application permission. But For other requests - how can I know what's wrong (what's the error message received)?