I am trying to get all events associated with a user (in order to cancel them). Here is the API doc
I am able through Powershell and Graph API to see a user, and also to sign out this user with the API.
I am using a token got from oauth2 protocol, with grant type client_credentials. I put the permission "Calendars.ReadWrite".
But I only get 404 errors when trying to get the events with :
Invoke-WebRequest 'https://graph.microsoft.com/v1.0/users/864abe35-a43f-44c3-9d24-ea7d2ce53907/events' -ContentType 'application/json' -Method Get -Headers @{Authorization = "Bearer $token"}
This strange thing is that I can get the user array, or revoke his session…
Do this endpoint not working ?
Thank you
EDIT : Answer was that when a user does not have mailboxes, events URL does not exist, and lead to a 404. It works with user having mailbox.
2
Answers
Finally, it appeared that the accounts who do not have any exchange mailbox will not result with an empty return, but with an unexisting URL (that's explains the 404).
It works with an account which holds a mailbox.
Please provide the full response (with error message etc.).
Have you granted admin consent to
Calendars.Write
?In the azure portal, go to
Home > App registrations > your app registration
and then click on "API permissions". I don’t think this is the issue but better to be safe than not. I would rather expect a 403 Forbidden if this is the problem.Are you sure that the guid of the user is correct? Check if the user with this
Id
exists in your tenant.Has the user a valid licence?
Check if the user has a calendar. Use Get calendar.
Maybe the user has only group calendar(s). If this is the case, you need
Group.Read.All
orGroup.ReadWrite.All
.Try to get oulook meetings from a user where you are sure that he has a calendar.