我正在将我现有的应用程序与Graph API集成在一起。使用Outlook API,我们能够创建“日历webhooks”和“日历事件webhooks”。根据文档,日历事件webhooks是Subscription
与resource_type
me/events
的组合。是否有任何修饰符可将范围缩小到日历ID?另外,有什么方法可以订阅要添加或删除的日历?
我尝试me/events/{id}
,me/events
,/me/calendars/{id}/events
和/me/calendars/{id}
无济于事
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'])
我唯一得到的答复是503 (Gateway timeouts)
和
400 Client Error: Bad Request for url: https://graph.microsoft.com/v1.0/subscriptions
答案 0 :(得分:1)
根据documentation,您只能订阅/me/events
:
以下是订阅的resource属性的有效值:
- 邮件:
me/mailfolders('inbox')/messages
me/messages
- 联系人:
me/contacts
- 日历:
me/events
- 用户:
users
- 组:
groups
- 对话:
groups('*{id}*')/conversations
- 驱动器:
me/drive/root
- 安全警报:
security/alerts?$filter=status eq ‘New’