无法通过Office 365 REST API

时间:2016-05-25 22:52:06

标签: office365 office365api office365-restapi

似乎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文档中找到有关任何此类约束的任何内容。我错过了什么?

1 个答案:

答案 0 :(得分:0)

我可以重现这个问题。但是,在将时区更改为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 Developer团队联系。