Failed to list all calendars with microsoft graph api - microsoft-graph-api

I'm currently trying to deal with calendars using graph api.
Last week, I've tried to use
https://graph.microsoft.com/v1.0/users/{user_id}/calendars
and
https://graph.microsoft.com/v1.0/users/{user_id}/calendars?$top=500
to list the calendars from my_calendar groups.
However, only the calendars I've created months ago can be listed, and all the calendars I create today are not listed. (there are only 15 calendars)
Note. I've tried to use
UI: https://outlook.office.com/calendar/view/month
graph explorer sending api: post https://graph.microsoft.com/v1.0/users/{user_id}/calendars
to create the calendar.
However, all the new calendars I create can not be listed by the list calendars api.
Best regards,
Thank you in advance~!

List calendars - Get all the user's calendars (/calendars navigation property), get the calendars from the default calendar group or from a specific calendar group.
For getting delegated shared calendars, use this documentation.

Related

create a calendar event for a whole team ( participants) using the graph api

Is it possible to create a calendar event for a whole team using the graph api? Right now, the calendar is coming only in the logged in/organizer account through which the event/meeting is being created But, I want to have this feature for every users/attendees/participants in their calendars. If it is not possible, then, can a separate meeting invite be sent to every users in the attendees list to accept the event/meeting so that they can be notified about the event which has been created and which they need to attend.
You can create Microsoft 365 group of users and use below API to create event.
POST /groups/{id}/calendar/events
The calendar can be one for a user, or the default calendar of a Microsoft 365 group.
Ref Doc: https://learn.microsoft.com/en-us/graph/api/calendar-post-events?view=graph-rest-1.0&tabs=http

Is it possible to get all events from all calendars regardless of calendar group

I want to use a Graph request to pull all events from all calendars regardless of a calendar group. What I have tried:
GET /me/calendar/events
GET /me/calendarGroups/{id}/calendars/{id}/events
Case one I get from one calendar from the default calendar.
case two I get from a specific calendar in any group.
Any way of getting events from all calendars everywhere?
To get all events from all user's calendars you can use Client Credential flow which gives App only token and use it to query all calendars using below call
https://graph.microsoft.com/v1.0/users/userid/calendars
and then use the calendarid's and pull the events by using the below call for each calendar_id.
https://graph.microsoft.com/v1.0/users/1ab4e76f-5f52-44b8-8a72-7d03c05e6ff4/calendars/AAMkAGI0Mjk2NTQ5LTE4MjctNDE1Yy04Nzc0LWIxNzA0MDBkNDkwZABGAAAAAABAJhtsoNeXR49KeByGVNbsBwB0tR3-uC1cSqrKkE00IGLeAAAAAAEGAAB0tR3-uC1cSqrKkE00IGLeAAAAAB89AAA=/events
There is no direct call to get all events from all the calendars as of now. There is already a feature request raised in the Microsoft Graph Feature Request Forum, please upvote it so that it may be implemented in the future.

Shared calendars through Microsoft Graph

I'm viewing shared calendars in my app. It uses delegated workflow with permission Calendar.Read.Shared and Users.ReadBasic.All
I don't really understand how to sharing works when it comes to the API
Some users shared calendars are not shown when accessing /users/{userId}/calendars (they are visible in outlook)
Some users calendars are returned when using /users/{userId}/calendars but when trying to access the calendar events I get 403. Why are the calendar available to access but not the events? (they are visible in outlook).
I'm able to get both calendars and event in some cases
I'm guessing there are some settings on the calendars themselves that make this difference but I'm not able to see the difference in the calendar object I get from the /users/{userId}/calendars response or from the calendars when I view them in outlook.
I have verified the behaviour in Graph Explorer so it is not code related.
Is there another way to access all shared calendars?

Get shared O365 calendars with Graph API

I need to get information (events and tasks) about shared calendars with Graph API.
In my Office365 account, I have several shared calendars ( calendars that other people have shared with me ) and I have any kind of privileges on those: from the client or from the browser I can read/write appointments and task. So I don't understand why I can't retrieve information about those shared calendars with Graph API. I tried
https://graph.microsoft.com/v1.0/me/calendars
but I get only my personal calendars, and
https://graph.microsoft.com/beta/me/calendarGroups/{shared-calendar-group-id}/calendars
but I get an empty response.
Can someone help me?
Get shared calendars
https://graph.microsoft.com/v1.0/users('user id who shared the calendar to you')/calendars
official guidline

Microsoft Graph API: Can we read multiple users calendar events using one Microsoft account within an organization or team

I am trying to find a way to read calendar events of my team and can schedule something based on everyone's availability.
I was able to fetch my calendar events successfully. But I am curious if we can get details of calendar events of my colleagues within my team or organization.
Is there a way we can achieve this?
If yes, it would be helpful if anyone can share some insights on this.
Thank you in advance.
If you grant the app permissions to read calendars from all users, then you can achieve what you want.
Then, you can get the list of users IDs from /users.
Using the IDs, you can retrieve the user calendars. If you only desire the available times in a scheduling assistant way, then you can use the Find Meeting Times API also.

Resources