I’m currently researching Microsoft Graph API using .net and Microsoft.Graph Client Library 5.0.0 (https://www.nuget.org/packages/Microsoft.Graph/) and a GraphTutorial console app (https://developer.microsoft.com/en-us/graph#get-started).
When trying to grab my outlook calendar via the API, I’m getting Microsoft.Graph.Models.ODataErrors.ODataError
exception. The problem is that it’s not telling me what exactly is wrong.
How can I get detailed information on the error? Such as, is it about permissions, query, or something different?
I tried diving into the Exception object, but I couldn’t find anything useful.
2
Answers
OK, so it appears that Microsoft Graph API responses are not very verbose, but are rather using HTTP status codes to communicate errors. The full list of codes and their meaning cane be found here: https://learn.microsoft.com/en-us/graph/errors
As for my question, you can see 403 response status code in the exception object (screenshot above) which is to be understood as:
According to Microsoft, on some occassions a more descriptive JSON object can be returned:
However, I'm still not sure which property of an exception object I should look in for this JSON response.
If you are using C# SDK you can add
try-catch
and catchODataError