1
votes

I am able to create a single outlook calendar event but how to create multiple at the same time, is there is any way using Microsoft graph api?

I have tried passing an array of events to api, throwing JSON error

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)
    })

for one event it's working but I need to add multiple events lets say 2 pm to 3 pm and 6 pm to 7 pm, for loop consuming too much time

1

1 Answers

0
votes

Currently the 'Events' api's post method allows to send request body with information only for a single event.

In order to create multiple events in a single request you can batch your request for various endpoints as a request body and post it to Batch Graph Request Endpoint.

You can find more info on Json Batching Multiple Graph Requests here