How to manage time ranges for delta polling on calendar views ?

Jean Lambert Hétault 0 Reputation points
2025-02-26T08:31:39.1433333+00:00

I'm trying to synchronize calendar events from Outlook with events from my web application.

From what I've gathered, I should use the delta() function on the calendarView ressource.

This requires that a time range to be specified, so the changes will be tracked only for this time range.

So in the code I would do my initial delta request like this:

_appClient.users().byUserId(user_id).calendarView().delta().get(requestConfiguration -> {
	requestConfiguration.queryParameters.startDateTime = "2025-01-01T00:00:00Z";
	requestConfiguration.queryParameters.endDateTime = "2025-02-01T00:00:00Z";
});

I can process the received events and store the delta token.

This delta token is then used to do the next request, fetching only incremental changes, like so:

DeltaRequestBuilder deltaRequestBuilder = new DeltaRequestBuilder(delta_state, _appClient.getRequestAdapter());
deltaRequestBuilder.get();

In this example I set the time range for the month of january, but this time range will surely become out of date as the time passes. Is there a way we can shift this time range without doing an initial delta request ?

It seems to me that the time range on which we want to track changes is actually stored in the delta state. If I try to fetch the changes using a delta state and specifying a new time range, the new time range is not taken into account:

DeltaRequestBuilder deltaRequestBuilder = 
deltaRequestBuilder.get(requestConfiguration -> {
	requestConfiguration.queryParameters.startDateTime = "2025-02-01T00:00:00Z";
	requestConfiguration.queryParameters.endDateTime = "2025-03-01T00:00:00Z";
});
deltaRequestBuilder.get();
// The specified time range is ignored

I could simply put a very big time range spanning multiple years, but that doesn't seem like good idea since all occurences of reccuring events are listed.

Note: I'm using the java sdk

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,148 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Akhil Nasalwai - MSFT 660 Reputation points Microsoft Vendor
    2025-02-27T18:10:58.8+00:00

    Hello Jean Lambert Hétault,

    Thank you for reaching out to Microsoft Support!!

    The delta token essentially acts as a state checkpoint, capturing the state of the data at the time of the initial delta query. Unfortunately, there is no way that you can update the time range for the delta token. As mentioned, once you perform the delta query, the time range is bound to that state. The delta state keeps track of changes from the initial time range onward.

    If you require a fresh full synchronization for a new time range, you must initiate a new delta query without reusing the previous delta token. However, this is not efficient for recurring events.

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.