【发布时间】:2026-02-05 11:00:01
【问题描述】:
我正在编写一个使用Microsoft Graph API v1.0 与 Office365 事件同步的应用程序。
创建单个事件时,该事件按预期创建:
Response Status Code: 201 Created
Request URL: https://graph.microsoft.com/v1.0/me/calendars/<myCalendarId>/events
Request Method: POST
Request Payload:
{
"subject": "single event",
"start": {
"dateTime": "2020-02-15T09:00:00",
"timeZone": "Europe/Berlin"
},
"end": {
"dateTime": "2020-02-15T10:00:00",
"timeZone": "Europe/Berlin"
},
"attendees": [],
"type": "singleInstance",
"location": {
"displayName": null
},
"recurrence": null
}
但是,如果我为重复事件发送创建请求,则会收到错误响应。
Response Status Code: 500 Internal Server Error
Request URL: https://graph.microsoft.com/v1.0/me/calendars/<myCalendarId>/events
Request Method: POST
Request Payload:
{
"subject": "test recurring event",
"start": {
"dateTime": "2020-02-14T09:00:00",
"timeZone": "Europe/Berlin"
},
"end": {
"dateTime": "2020-02-14T10:00:00",
"timeZone": "Europe/Berlin"
},
"attendees": [],
"location": {
"displayName": null
},
"recurrence": {
"pattern": {
"daysOfWeek": [],
"type": "daily"
},
"range": {
"numberOfOccurrences": "2",
"recurrenceTimeZone": "Europe/Berlin",
"startDate": "2020-02-14",
"type": "numbered"
}
}
}
Response Body:
{
"error": {
"code": "ErrorInternalServerError",
"message": "An internal server error occurred. The operation failed.",
"innerError": {
"request-id": "2d97931c-e08c-45a8-8167-5849df53a694",
"date": "2020-02-14T14:38:28"
}
}
}
我觉得奇怪的是添加重复设置会导致Internal Server Error。
如何使用 API 创建重复事件?
【问题讨论】:
-
响应 body 包含什么?通常,您会在其中发现人类可读的错误消息或类似内容。
-
我已经编辑了问题并添加了响应正文。
-
好吧,如果他们真的没有给你更多,你实际上需要问 MS。有时,此类 API 会以 500 错误代码响应,而在 400 Bad Request 或类似情况更合适的地方。然后您通常会收到一条消息,说明该请求有什么特别错误的地方。但如果这是一个“正版”500,那么可能只有 MS 才能告诉你,哪里出了问题。有时这些只是暂时的问题,所以也许在几个小时左右再试一次。否则,您可能必须找到提交错误报告的地方。