Reputation: 1
I'm working on integrating my existing app with the Graph API. Using the Outlook APIs we were able to create "calendar webhooks" and "calendar event webhooks". According to the docs, calendar events webhooks are Subscription
s with the resource_type
me/events
. Is there any modifier to scope down to a Calendar ID? Additionally, is there any way to subscribe to calendars being added or removed?
I've tried me/events/{id}
, me/events
, /me/calendars/{id}/events
, and /me/calendars/{id}
to no avail
API_BASE = 'https://graph.microsoft.com/v1.0'
def api_url(fmt, *args, **kwargs):
"""Helper for generating API URLs"""
return API_BASE + fmt.format(*args, **kwargs)
def _create_push_subscription(self, callback_url):
"""Create a push subscription"""
expiration = now() + timedelta(days=2)
# Initialize some parameters
data = {
'resource': '/me/calendars/{}/events'.format(calendar_id),
'subscriptionExpirationDateTime': str(expiration.isoformat()).replace('+00:00', 'Z'),
'changeType': 'created,deleted,updated',
'notificationURL': callback_url,
}
# Create the subscription
resp = self.session.post(api_url('/subscriptions'), json=data)
# Return the channel ID and expiration date
return parse_datetime(resp['subscriptionExpirationDateTime'])
The only responses I've gotten are 503 (Gateway timeouts)
and
400 Client Error: Bad Request for url: https://graph.microsoft.com/v1.0/subscriptions
Upvotes: 0
Views: 36
Reputation: 33124
According to the documentation, you can only subscribe to /me/events
:
The following are valid values for the resource property of the subscription:
- Mail:
me/mailfolders('inbox')/messages
me/messages
- Contacts:
me/contacts
- Calendars:
me/events
- Users:
users
- Groups:
groups
- Conversations:
groups('*{id}*')/conversations
- Drives:
me/drive/root
- Security alert:
security/alerts?$filter=status eq ‘New’
Upvotes: 1