无法通过 Office 365 REST 添加旧日期的日历事件 API

Unable to add calendar event with old date via Office 365 REST API

似乎 Office 365 REST API 中存在某种限制,阻止添加具有较旧日期的事件,但我无法确定具体限制。例如,以下 JSON 负载导致请求失败并返回 400 响应:

{
    "Subject":"Task/Other",
    "Location":{},
    "Body": {
        "ContentType":"Text",
        "Content":"Appointment text"
    },
    "Start": {
        "DateTime":"1983-05-12T19:00:00",
        "TimeZone":"America/New_York"
    },
    "End": {
        "DateTime":"1983-05-12T19:30:00",
        "TimeZone":"America/New_York"
    }
}

但是,以下负载成功:

{
    "Subject":"Task/Other",
    "Location":{},
    "Body": {
        "ContentType":"Text",
        "Content":"Appointment text"
    },
    "Start": {
        "DateTime":"2016-05-12T19:00:00",
        "TimeZone":"America/New_York"
    },
    "End": {
        "DateTime":"2016-05-12T19:30:00",
        "TimeZone":"America/New_York"
    }
}

唯一的区别是最近的活动日期。我无法在 API 文档中找到有关任何此类约束的任何内容。我错过了什么?

我可以重现这个问题。但是,在我将时区更改为 UTC 后,问题就解决了。作为解决方法,我建议您首先将时间从 "America/New_York" 转换为 "UTC",然后使用 UTC 时间。

下面是我测试的样例,供大家参考:

POST: https://graph.microsoft.com/v1.0/me/events/
authorization: bearer {token}
Content-type: application/json
{
"Subject":"Task/Other",
"Location":{'DisplayName':'Water Cooler'},
"Body": {
    "ContentType":"Text",
    "Content":"Appointment text"
},
"Start": {
    "DateTime":"1983-05-12T19:00:00",
    "TimeZone":"UTC"
},
"End": {
    "DateTime":"1983-05-12T19:30:00",
    "TimeZone":"UTC"
}
}

要解决此问题,您可以尝试联系 here 的 Office 开发团队。