How to start using Delta function in Microsoft graph by skipping initial data - microsoft-graph-api

Microsoft recommends to use delta function in combination with Subscriptions/Notifications to synchronize mailbox. So my plan is:
Create subscription
Receive notification about new mail in inbox
Use delta function to get latest changes in the inbox
My mailbox already has several thousands of letters. If I run the query
https://graph.microsoft.com/v1.0/users/{id}/mailFolders/inbox/messages/delta
It will return in response #odata.nextLink with $skiptoken param many times and only after I get all the thousands of emails in my mailbox I will receive response with $deltatoken to track new changes.
Is there a way to get deltatoken after the first request? I don't want to synchronize the old messages. I want to skip all old messages in inbox and have a fresh start.

Today the delta query functionality does not support this scenario. To request new features please post ideas to uservoice

This is supported for some endpoints. You can use $deltaToken=latest to get just a deltaToken without any resource data. It's not, as far as I can tell, available for mailboxes… but who knows, maybe it will be soon.
This is not documented anywhere in the documentation for the specific APIs that do support it, but is instead documented in the Overview for change tracking. Why? Because Microsoft wants you to be sad all the time.

Related

How to get OrgContacts with Addresses with Microsoft Graph Delta endpoint?

I am trying to get the Org contacts of my tenant using this Delta endpoint:
GET https://graph.microsoft.com/v1.0/contacts/delta
which is documented here.
Unfortunately, this is not returned the Address of my contacts. In order to retrieve the addresses, I am obliged to call this endpoint instead:
GET https://graph.microsoft.com/v1.0/contacts
The issue is that I need to call the Delta endpoint because that returns the DeltaToken that I can use in the future to only pull the list of modified/deleted contacts.
Is there any workaround to do this, without having to go through both endpoints, the first one to get the DeltaToken, and the second one to get the addresses of my contacts? (PS: I tried the expand option with no luck).
Thanks!
AFAIK, Currently address of contacts is not returned using this delta endpoint.
Being said that, consider filing uservoice for your specific ask so it could be considered for future implementations.
Thanks.

Add reaction to existing posts or comments

How can we "like" or add other reactions to someone else's channel message or comment via the Graph API?
I've not done this myself, but it certainly looks possible. You need to reply to the message, as per https://learn.microsoft.com/en-us/graph/api/channel-post-messagereply?view=graph-rest-1.0&tabs=http and notice that it has a "reactions" collection. That would be populated with a chatMessageReaction type, as per https://learn.microsoft.com/en-us/graph/api/resources/chatmessagereaction?view=graph-rest-beta
Note of warning: chatMessageReaction is a beta type though, so just be aware you need to call the beta endpoint, and it has a risk to use in production code as things might change.
Update: We reached out to MS Support and received the following info: "The API to reply to a message using a POST /replies request is solemnly for issuing a reply to a message, and not to edit the status of the parent message itself. Moreover, the "update chatMessage" API which is a PATCH /messages and which is the only API to edit a parent message only supports updating the policyViolation property of a chatMessage. Essentially, there is currently no documented API / already-present API examples on how to add a reaction, making this purely unsupported."

Webhooks v/s polling for all users drives' within an Org (multi-tenant) - MS Graph

We are going to have a multi-tenant application that is going to be scanning files for each user per organization for multiple orgs. We would like to get notification if any user uploads/changes a file in the drive. There are at-least 2 options to retrieve those: either store delta link for each user and poll periodically to get the change or subscribe using webhooks to get notification on change. If we have 10k+ users, I am not sure if the first option is feasible. For the latter one, my only concern with webhook is do I have to register for each user separately? ie., does the resource need to be /users//drive/root or should it just be /drive/root? Since there is a limitation of no. of webhooks per app/tenant, I am not sure if creating webhooks for each user is a right approach.
Please advise.
The limitation applies to the users/groups objects (i.e. if you wanted to subscribe to users/groups being updated), not to the drives.
Yes, you need to subscribe to each drive individually, and to renew the subscriptions individually as well. If you want to save the number of roundtrips, you can group those operations in a batch.
You can also combine the delta + webhooks: do the initial sync with delta and store the token, register your webhook. And then trigger querying the delta link upon receiving a change notification. This way you get the best of both features and avoid regularly polling delta when there might not be any change.

Synchronization of outlook messages attributes (Flag, IsRead) and deletion status

According to this documentation Synchronize messages API users have ability to synchronize messages with pretty simple skipToken mechanics. And it works well for fetching new messages in folders.
But! What I'm also interested is how to sync flags and status like is message read or not.
For example I synced all messages from Inbox folder. After that user goes to his Outlook account and reads message and set some flag for this message.
How can I get this info? Should I resync all messages to get only those changes?
Also how I get notion about message removal? If some user deleted message from inbox, how I get to know which message was deleted without fetching all messages again?
You should use the Microsoft Graph API and move away from using the Outlook Rest API as it has been deemphasized with no more effort being put into the developer experience.
Use Microsoft Graph to synchronize and track changes by using the Delta query feature.
An initial sync call will happen with a Delta query. Make sure you select the properties you care about:
GET https://graph.microsoft.com/v1.0/me/mailfolders/AQMkADNkNAAAgEMAAAA/messages/delta?$select=subject,sender,isRead
Prefer: odata.maxpagesize=50
If the response has an #odata.nextlink in the response JSON object, GET that URL to the next page of results.
If the response has an #odata.deltaLink in the response JSON object, cache that URL until the next time you want to check for changes.

Asana api to get content from inbox

I want to get updates from asana inbox directly using asana api.
Is there any way this can be done using api as i am unable to find anything in api documentation. If there is anything that i might have missed in api please point me to that.
Unfortunately, we don't have an endpoint for the inbox. As was discussed in another question, you may be able to get this by grabbing every task across all projects into a local database. You would then need to search for tasks where assignee_status is set to inbox.

Resources