skip to Main Content

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


  1. Chosen as BEST ANSWER

    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.


  2. Please provide the full response (with error message etc.).

    1. 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.

    2. Are you sure that the guid of the user is correct? Check if the user with this Id exists in your tenant.

    3. Has the user a valid licence?

    4. Check if the user has a calendar. Use Get calendar.

    5. Maybe the user has only group calendar(s). If this is the case, you need Group.Read.All or Group.ReadWrite.All.

    6. Try to get oulook meetings from a user where you are sure that he has a calendar.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search