Juan Carlos Mendoza
Juan Carlos Mendoza

Reputation: 5814

Microsoft-Graph API how to send multi-date event

I have a Java application that uses Microsoft Graph API to send mails and schedule events. I'm able to create an event posting a request with a JSON in the following format:

{
    "subject": "Test event",
    "start": {
        "dateTime": "2017-12-01T09:00:00",
        "timeZone": "SA Western Standard Time"
    },
    "end": {
        "dateTime": "2017-12-01T10:00:00",
        "timeZone": "SA Western Standard Time"
    },
    "body": {
        "contentType": "TEXT",
        "content": "This is a test"
    },
    "attendees": [{
        "emailAddress": {
            "address": "[email protected]",
            "name": "someuser"
        }
    }]
}

This creates an event on 12-01-2017 from 9:00 AM - 10:00 AM. That's enough when the event is for a single day. But now I need to create a multi-date event that occurs on 12-01-2017 and on 12-02-2017, both dates from 9:00 AM to 10:00 PM. So my question is, what would be the JSON representation needed to create this event?

Upvotes: 2

Views: 348

Answers (1)

Marc LaFleur
Marc LaFleur

Reputation: 33114

You need to set a recurrence pattern for the event:

"recurrence": {
    "pattern": {
        "type": "daily",
        "interval": 1
    },
    "range": {
        "type": "endDate",
        "startDate": "2017-12-01",
        "endDate": "2017-12-01"
    }
}

The complete payload would look something like this:

{
    "subject": "Test event",
    "start": {
        "dateTime": "2017-12-01T09:00:00",
        "timeZone": "SA Western Standard Time"
    },
    "end": {
        "dateTime": "2017-12-01T10:00:00",
        "timeZone": "SA Western Standard Time"
    },
    "body": {
        "contentType": "TEXT",
        "content": "This is a test"
    },
    "attendees": [{
        "emailAddress": {
            "address": "[email protected]",
            "name": "someuser"
        }
    }],
    "recurrence": {
        "pattern": {
            "type": "daily",
            "interval": 1
        },
        "range": {
            "type": "endDate",
            "startDate": "2017-12-01",
            "endDate": "2017-12-01"
        }
    }
}

Upvotes: 2

Related Questions