Skip to content

All day event dates incorrect in calendar ListItems created in Graph API #2755

@mikepowell

Description

@mikepowell

Category

  • Question
  • Typo
  • Bug
  • Additional article idea

Expected or Desired Behavior

When creating an all-day calendar ListItem, the start time should be 00:00 on the start date, and the end time should be 23:59 on the end date.

Observed Behavior

The resulting ListItem starts at 00:00 on the day before the expected start date. The end date and time are as expected.

Steps to Reproduce

POST https://graph.microsoft.com/v1.0/sites/root:/{sitename}:/lists/{listname}/items
// Single day, all-day event on 8/31/2018
{
    "fields": {
        "Title": "Test Event",
        "EventDate": "2018-08-31T00:00:00",
        "EndDate": "2018-08-31T23:59:00",
        "fAllDayEvent": true
    }
}

Result

"fields": {
    "EventDate": "2018-08-30T00:00:00Z",  // A day earlier than expected
    "EndDate": "2018-08-31T23:59:00Z",
    ...
}

Note that the results are the same if EventDate and EndDate are specified with no time information, e.g. "2018-08-31".

Workaround

Adding a day to the EventDate field causes the created item to be correct. This works even if creating a single-day event, where it's necessary to specify a start date that's later than the end date:

{
    "fields": {
        "Title": "Test Event",
        "EventDate": "2018-09-01T00:00:00",  // Add a day.
        "EndDate": "2018-08-31T23:59:00", 
        "fAllDayEvent": true
    }
}
"fields": {
    "EventDate": "2018-08-31T00:00:00Z", // Correct!
    "EndDate": "2018-08-31T23:59:00Z",
    ...
}

Related StackOverflow question here

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:csom/rest/apiCategory: SharePoint Client Side Object Model SDK / REST APIstatus:trackedCurrently tracked with Microsoft’s internal issue tracking system. DO NOT ADD/REMOVE (MSFT managed)type:archive-old-issueIssues which are closed as tool old for active work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions