如何使用Microsoft图形添加多个日历事件

时间:2019-08-08 06:41:09

标签: javascript node.js outlook outlook-restapi

我能够创建一个Outlook日历事件,但是如何同时创建多个事件,是否可以使用Microsoft graph api?

我尝试将事件数组传递给api,并抛出JSON错误

var event = {
    "subject": "Let's go for lunch",
    "body": {
        "contentType": "HTML",
        "content": "Does late morning work for you?"
    },
    "start": {
        "dateTime": "2017-04-15T12:00:00",
        "timeZone": "Pacific Standard Time"
    },
    "end": {
        "dateTime": "2017-04-15T14:00:00",
        "timeZone": "Pacific Standard Time"
    },
    "location": {
        "displayName": "Harry's Bar"
    },
    "attendees": [{
        "emailAddress": {
            "address": "samanthab@contoso.onmicrosoft.com",
            "name": "Samantha Booth"
        },
        "type": "required"
    }]
}


client
    .api('/me/events')
    .post(event, (err, res) => {
        console.log(res)
    })

对于一个事件,它正在运行,但是我需要添加多个事件,比如说下午2点到3点以及6点到7点,因为循环消耗了太多时间

1 个答案:

答案 0 :(得分:0)

当前'Events' api的post方法允许仅向单个事件发送带有信息的请求正文。

为了在单个请求中创建多个事件,您可以将对各种端点的请求作为请求主体进行批处理并将其发布到 Batch Graph Request Endpoint

您可以找到有关的更多信息 Json Batching Multiple Graph Requests here