I'm working with the Microsoft Graph api to try and sync calendar events from Outlook. I was looking at this article concerning the Outlook api, which suggested I add the header odata.track-changes
to my request and I would receive a deltaToken
, which I could use on a later request to fetch only those events which had been updated or created since the last sync.
I have been successful fetching events, but I'm not getting a deltaToken back :/
Is this only supported in the Outlook api? Graph's response has Preference-Applied: odata.track-changes
, so it's acknowledging my header. Here's my sample request:
GET /v1.0/me/calendar/calendarView
?startDateTime=2016-09-01T00:00:00.0000000
&endDateTime=2099-01-01T00:00:00.0000000
HTTP/1.1
Host: graph.microsoft.com
Authorization: Bearer XXX
Prefer: odata.track-changes
Prefer: odata.maxpagesize=3 //for testing
Cache-Control: no-cache
And my sample response:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('')/calendar/calendarView",
"value": [
{
"@odata.etag": "",
"id": "",
"createdDateTime": "2016-08-04T14:00:25.8552351Z",
"lastModifiedDateTime": "2016-08-25T14:43:54.9950828Z",
"changeKey": "",
"categories": [
"Orange category"
],
"originalStartTimeZone": "Eastern Standard Time",
"originalEndTimeZone": "Eastern Standard Time",
"responseStatus": {
"response": "organizer",
"time": "0001-01-01T00:00:00Z"
},
"iCalUId": "",
"reminderMinutesBeforeStart": 15,
"isReminderOn": true,
"hasAttachments": false,
"subject": "Closing on House",
"body": {
"contentType": "html",
"content": ""
},
"bodyPreview": "",
"importance": "normal",
"sensitivity": "normal",
"start": {
"dateTime": "2016-09-08T19:30:00.0000000",
"timeZone": "UTC"
},
"end": {
"dateTime": "2016-09-08T21:30:00.0000000",
"timeZone": "UTC"
},
"location": {
"displayName": "245 E Main St",
"address": {
"street": "245 E Main St",
"city": "Somewhere",
"state": "NY",
"countryOrRegion": "United States",
"postalCode": ""
}
},
"isAllDay": false,
"isCancelled": false,
"isOrganizer": true,
"recurrence": null,
"responseRequested": true,
"seriesMasterId": null,
"showAs": "busy",
"type": "singleInstance",
"attendees": [],
"organizer": {
"emailAddress": {
"name": "",
"address": ""
}
},
"webLink": "https://outlook.office365.com/owa/?ItemID="
},
{
"@odata.etag": "",
"id": "",
"createdDateTime": "2016-08-19T18:02:39.0607411Z",
"lastModifiedDateTime": "2016-08-19T18:04:10.548447Z",
"changeKey": "",
"categories": [
"Green category"
],
"originalStartTimeZone": "UTC",
"originalEndTimeZone": "UTC",
"responseStatus": {
"response": "organizer",
"time": "0001-01-01T00:00:00Z"
},
"iCalUId": "",
"reminderMinutesBeforeStart": 15,
"isReminderOn": true,
"hasAttachments": false,
"subject": "Moving (off work)",
"body": {
"contentType": "html",
"content": ""
},
"bodyPreview": "",
"importance": "normal",
"sensitivity": "normal",
"start": {
"dateTime": "2016-09-10T00:00:00.0000000",
"timeZone": "UTC"
},
"end": {
"dateTime": "2016-09-13T00:00:00.0000000",
"timeZone": "UTC"
},
"location": {
"displayName": "",
"address": {}
},
"isAllDay": true,
"isCancelled": false,
"isOrganizer": true,
"recurrence": null,
"responseRequested": true,
"seriesMasterId": null,
"showAs": "oof",
"type": "singleInstance",
"attendees": [],
"organizer": {
"emailAddress": {
"name": "",
"address": ""
}
},
"webLink": "https://outlook.office365.com/owa/?ItemID="
},
{
"@odata.etag": "",
"id": "",
"createdDateTime": "2016-09-13T19:05:20.8438647Z",
"lastModifiedDateTime": "2016-09-13T19:05:22.1899702Z",
"changeKey": "",
"categories": [],
"originalStartTimeZone": "America/New_York",
"originalEndTimeZone": "America/New_York",
"responseStatus": {
"response": "organizer",
"time": "0001-01-01T00:00:00Z"
},
"iCalUId": "",
"reminderMinutesBeforeStart": 15,
"isReminderOn": true,
"hasAttachments": false,
"subject": "Coffee Break",
"body": {
"contentType": "html",
"content": ""
},
"bodyPreview": "",
"importance": "normal",
"sensitivity": "normal",
"start": {
"dateTime": "2016-09-15T20:15:00.0000000",
"timeZone": "UTC"
},
"end": {
"dateTime": "2016-09-15T21:15:00.0000000",
"timeZone": "UTC"
},
"location": {
"displayName": "",
"address": {}
},
"isAllDay": false,
"isCancelled": false,
"isOrganizer": true,
"recurrence": null,
"responseRequested": true,
"seriesMasterId": null,
"showAs": "busy",
"type": "singleInstance",
"attendees": [],
"organizer": {
"emailAddress": {
"name": "",
"address": ""
}
},
"webLink": "https://outlook.office365.com/owa/?ItemID="
}
]
}
I redacted anything I thought could be mildly sensitive. Ultimately, my Laravel app is trying to sync events starting 4 months back, and go forever into the future.
If there's a more efficient/better way to do it, I'm open to suggestions. If it matters, these results were generated with Postman. Any help or clarity on this is appreciated.