5
votes

I'm using the Office 365 REST api to access my account's calendars. I'd like to access all the calendars my account has access to, in particular the meeting rooms calendars appearing in the "Other calendars" section in my Office 365 interface.

For now, if I query the "https://outlook.office365.com/api/v1.0/me/calendars" endpoint, I only got the calendars I own, not the meeting rooms calendars.

Any clue on how to get them (via Office 365 REST API) ?

2

2 Answers

3
votes

The REST API doesn't support access to other user's calendars when logging in as a user. You can use the client credentials model to grant the app access to all calendars in the organization and access them that way.

1
votes

I've been able to do what I believe you're asking about (using the office 365 API to get the events from calendars which have been shared with your outlook calendar) by using the following endpoint:

.../api/v2.0/Users('PRIMARY_USER_ID')/Calendars('SHARED_CALENDAR_ID')/Events

I'm not sure if this endpoint would get you access to ones you have partial access to, but you should be able to grab events/info from any calendar that has been directly shared with your outlook/office 365 account.

  • The PRIMARY_USER_ID (just what I'm calling it here) comes back to you as part of the response object when you first sign in with your outlook account and go through Microsoft's auth process. This isn't the ID of the calendar you're trying to access, but the idea of the primary calendar (the one you can find at the api/v2.0/me endpoint) that the other calendars are shared with. All of the IDs I've seen have come back in the form of a bunch of letters and numbers separated by dashes.

  • The CALENDAR_ID is the ID of the shared calendar you're trying to get the events from. You can see these IDs for each of your shared calendars if you make a request to .../api/v2.0/me/calendars/. This will return each of the calendars that are shared with you, info about the owner, and the 'ID' of that calendar.

If you plug in those ids, and make a request to url above, you should be able to get calendar events back from the API.