如何通过Outlook 365 Rest Api添加定期日历事件?

时间:2016-08-25 23:04:12

标签: php api calendar office365 recurrence

我使用PHP访问Outlook 365 REST API。我通过POST将有效负载发送到https://outlook.office.com/api/v2.0/me/events并收到500错误作为回报。我的有效负载如何配置错误?

{
    "Subject":"Test Event",
    "Location": { 
        "DisplayName":"Test Location"
        },
    "Start": {
        "DateTime":"2016-09-06T00:00:00Z",
        "TimeZone":"UTC"
        },
    "End":{
        "DateTime":"2016-09-06T02:00:00Z",
        "TimeZone":"UTC"
        },
    "Body":{
        "ContentType":"HTML",
        "Content":"Stephen Colbert"
        },
    "Recurrence":{
        "Pattern":{
            "Month":0,
            "DayOfMonth":0,
            "FirstDayOfWeek":"Sunday",
            "Index":"First",
            "Type":"Daily"
            },
        "Range":{
            "NumberOfOccurrences":0,
            "Type":"EndDate",
            "EndDate":"2016-09-09",
            "StartDate":"2016-09-05",
            "RecurrenceTimeZone":"Eastern Standard Time"
            }
        }
}

1 个答案:

答案 0 :(得分:2)

您是如何创建重复活动的?如果您想使用每日模式创建会议,我们还需要使用时间间隔来指定出现次数之间给定重复类型的单位数。

以下是创建2016-09-05至2016-09-09每天发生的经常性会议的演示示例:

{
"Subject":"Test Event",
"Location": { 
    "DisplayName":"Test Location"
    },
"Start": {
    "DateTime":"2016-09-06T00:00:00Z",
    "TimeZone":"UTC"
    },
"End":{
    "DateTime":"2016-09-06T02:00:00Z",
    "TimeZone":"UTC"
    },
"Body":{
    "ContentType":"HTML",
    "Content":"Stephen Colbert"
    },
"Recurrence":{
    "Pattern":{
       "Interval":1,
        "Type":"Daily"
        },
    "Range":{
        "NumberOfOccurrences":5,
        "Type":"EndDate",
        "EndDate":"2016-09-09",
        "StartDate":"2016-09-05",
        "RecurrenceTimeZone":"Eastern Standard Time"
        }
    }

}

您可以考虑使用Outlook UI创建周期性事件,以帮助理解RecurrencePattern参数。 here是一个类似的帖子供您参考。