Home > Net >  Microsoft Graph API I can't access my calendar (ResourceNotFound)
Microsoft Graph API I can't access my calendar (ResourceNotFound)

Time:05-31

I work with a client who wants to retrieve events from an outlook calendar.

So I registered from the azure portal an application to access the API.

I manage to generate the token and also to load my user infos with urls :

https://login.microsoftonline.com/{tenantid}/oauth2/v2.0/token (worked)
https://graph.microsoft.com/v1.0/users (worked)

For scope for generate my token, I use "https://graph.microsoft.com/.default".

When I want to access my calendar (the email of my azure account and the same as my outlook account) I have an error :

https://graph.microsoft.com/v1.0/users/{user_id}/calendar

My response :

enter image description here

Screen of my calendar :

enter image description here

From this url :

https://outlook.live.com/calendar/0/view/month

Permissions of my app are done.

enter image description here

To summarize, I can access my user info but my calendar seems to be non-existent. How can I make my calendar known to my application? Thanks !

CodePudding user response:

The error Resource not found usually occurs if the users don't have active licenses assigned to the accounts.

I tried to reproduce the same error in my environment

I have registered an application in Azure AD and granted below API permissions:

enter image description here

I got the access token with same scope https://graph.microsoft.com/.default as below:

enter image description here

I'm able to access the users successfully as below:

enter image description here

I tried to access calendar for specific user who does not have any active O365 license like below:

enter image description here

I got "Resource not found" error if the user has no license like below:

enter image description here

I tried to access calendar of specific user who have active O365 licenses like below:

enter image description here

I got the response successfully like below:

enter image description here

So, make sure to have these licenses active while you are trying to get calendar of Outlook.

If still the error persists, please check this Microsoft Q&A

  • Related