Get the latest delta token for inbox(messages) using Graph api through java program

vamsi krishna 26 Reputation points
2022-08-18T06:47:12.037+00:00

Hi team,

I'm trying to get the latest delta token for Inbox (messages) directly. I have tried the below URL using graph explorer tool, and it worked fine and able to get the latest delta token also.

https://graph.microsoft.com/v1.0/users/abcd@xyz.com/mailFolders/inbox/messages/delta?$deltaToken=latest  

When I try to do the same request using the Graph API programmatically using JAVA I'm unable to get the latest delta token, instead I'm getting skip tokens again.

Please check the below code block.

LinkedList<Option> requestOptions = new LinkedList<Option>();  
requestOptions.add(new QueryOption("$deltaToken","latest"));				  
MessageDeltaCollectionPage deltaResponse = graphServiceClient.users(userEmail).mailFolders("inbox").messages()  
			.delta()  
			.buildRequest(requestOptions)  
			.get();   

Is there any way we can get the latest delta token directly without going through all the skipToken scenario.
I'm using graph dependency-5.13.0 in my java application.

Thanks.

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

Accepted answer
  1. ShivaniRai-MSFT 2,726 Reputation points
    2022-08-18T09:47:26.143+00:00

    Hi @vamsi krishna ,

    According to this documentation, $deltatoken=latest is only supported for directory resources (users, groups etc.) and resources in OneDrive and SharePoint also support this feature. This feature is not supported for mail messages as of now. As per my testing I am getting delta link using this parameter for mail messages but its not the latest one and resource data is also coming which we should not get as stated in the documentation (Append $deltaToken=latest to the delta function and the response will contain a @odata.deltaLink and no resource data). This could be because the feature is not yet supported for mail resource.

    Also, If you want you can submit a feature request idea here which will be monitored by Microsoft team.

    Hope this helps.

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


0 additional answers

Sort by: Most helpful