How to access shared calendars from Office REST API?

前端 未结 3 779
醉话见心
醉话见心 2020-12-16 05:31

This question has been asked several times and as per answers such as this it seems the API didn\'t support this then until recently as here which mentions that there are ne

相关标签:
3条回答
  • 2020-12-16 06:08

    Updated. I found a working solution.

    GET /users('{id}')/calendars('{id}')/events

    GET /me/calendars('{id}')/events

    There are a few rules for how you need to share it and can be found at: https://developer.microsoft.com/en-us/graph/docs/concepts/known_issues#calendars

    An alternate workaround:

    You can access group calendars and group events using the API. Group calendars can be shared with anyone inside or outside your organization. Rather than sharing a users calendar, simply create a Group, add any members who you want read/write access. As long as a user is a member of that group, any events added to the groups calendar, will come through in the standard /me/events GET request.

    I found you need to have the following permissions granted:

    • Calendars.Read (Calendars.ReadWrite if write needed)
    • Calendars.Read.Shared (Calendars.ReadWrite.Shared if write needed)
    • Group.Read.All (Group.ReadWrite.All if write needed)

    Good Luck!

    0 讨论(0)
  • 2020-12-16 06:14

    A lot of stuff going on here :) However it seems the crux here is that you're expecting /Me/Calendars to include shared calendars. It does not. In order to access someone else's calendar that has been shared, you must access via the /Users/<id>/Calendars/ URL.

    So for example if bob@contoso.com logs in, and bill@contoso.com has shared his calendar with him, then:

    • /Me/Calendars would ONLY show calendars in Bob's mailbox
    • /Users/bill@contoso.com/Calendars would show calendars Bill has shared with Bob

    Update: It seems there's a blocking issue on our side. We're working on it.

    0 讨论(0)
  • 2020-12-16 06:17

    I've been able to do what I believe you're asking about (using the Outlook 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
    

    From this endpoint, 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 ID 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.

    0 讨论(0)
提交回复
热议问题