Get Change type in delta Events in Microsoft Graph Api - microsoft-graph-api

I am migrating from EWS to Microsoft graph and having problem in replacing flow "ExchangeService.syncFolderItems".
ChangeCollection<ItemChange> changedItems = exchangeService.syncFolderItems(calendarFolder.getId(),
FirstClassProperties, null, 512, NormalItems, syncState);
This gives me all the changes since last sync state with change type.
Now I need to replace this with Microsoft graph.
I saw Get delta api in Microsoft graph and also how to call it recursively using stale token. My query is, Get delta api is not returning the change Item type. Could someone suggest me the best way to implement this in Microsoft graph? Maybe the Apis that I need to use for this?
Note:This flow will be called by my service to get changes after fixed interval of time. Also I saw subscriptions ( https://learn.microsoft.com/en-us/graph/api/resources/subscription?view=graph-rest-1.0 )but not sure that could be used in my case as my service will be making a call to get changes for a meeting room after a fixed scheduled interval of time.
I am stuck here. Please help. Thanks in advance.

Deleted events will have a #removed property and only provide the id of the object as denoted here https://learn.microsoft.com/en-us/graph/delta-query-overview#resource-representation-in-the-delta-query-response
Updated objects will only include the updated properties and added objects should include all the data available. It's up to the 3rd party application (your app) to maintain a state on it's side to be able to differentiate between updated and created objects when using Delta queries.
Combining webhooks with Delta to trigger the sync instead of relying on a timer is a good approach to provide an end user experience that feels more real time

Related

How to retrieve all threads which have replies since a given timestamp?

I am ideally looking for an API that returns all the messages posted(including replies) since a given timestamp.
conversations.history is supposed to be the one I should be using, but it does not return replies, it only returns parent message (only if the timestamp of the parent message satisfies the "oldest" param I supply - i.e. if the oldest supplied in the query is later than parent's ts but earlier than replies, neither parent nor replies will be returned).
Hence, I am trying to find if there is any other API that returns the threads based on "oldest" timestamp. i.e. all the threads which have replies since a given timestamp.
Note: I looked at conversations.replies, it is only useful if you know which thread's replies you are fetching.
Currently there is no API to do what you aspire to do.
The best work around is manually fetching all threads data in-memory and then applying filter.
Did you find an alternative solution to this question? I have the same use case and when contacting Slack support I received the same response that we need to use the combination of conversations.history & conversations.replies. This will be quite an intensive and continuously growing number of calls if we need to call conversations.replies for all threaded messages just to filter out the timestamps that fit the date range. This would be catastrophic in the long run.
Ideally slack need to update conversations.replies API to support getting all replies between oldest & latest parameter just like in history.
Another alternative I am considering is to change the implementation and use the Events API instead of the Web Client API and use queueing to store all incoming messages then this will make sure that all messages are captured and stored then apply the required filters.

How to handle deleted Recurring master events using Microsoft delta queries

I am trying to move from EWS to Microsoft graph and facing problem while implementing syncFolderItems flow.
I need to track and update changes of all created, modified and deleted events using Microsoft graph apis.
I went through Microsoft documentation and found they have delta Api which returns only the changes which occurred from last sync. But I am not sure how recurring events should be handled using delta queries api.
Please help. Thanks in advance.
The current behavior is that only the master event (the one with the recurring pattern) will show up in the delta feed, not the other instances. Only instances that have been updated will then show up in the delta feed.
You would need to use the calendar view API to get all the occurrences of a specific master event (with a recurrence pattern) you see in the delta feed.
Additionally you can ask for recurring events instances to be added to the delta feed on Microsoft Graph uservoice.

People API in Microsoft Graph not returning the updated results

We recently updated the profile information in Azure active directory. when we use People API in graph explorer, it is not returning the latest information. How much time does it take normally to return the updated information?
The /me/people API is actually returning from a search index, not a real-time fetch from Azure Active Directory directly. The search index update depends on many characteristics of your AAD. It is safe to say you should see this reflected within 24 hours.
Obviously there is value in the people API with its underlying logic. If you wish to have the data updated instantly. You should use the /users/ to fetch the latest content.

Microsoft Graph Webhooks subscription on /users - not usable in current format

So having been to Ignite in 2017 I was really excited with the new possibilites the Webhooks in Microsoft Graph and binding to Azure functions.
Recently I got the chance to really explore this for myself.
I am looking at this from the perspective of Identity Management - I really want to see what kind of user onboarding/change management we can react to and process with Graph Webhooks and Azure functions. So I started looking at the beta endpoint and the Webhooks available for "/users"
The first thing that struck me was that in the beta only "updated" or "deleted" is a valid changetype. I really would like "created" - since that is when the most work would get done on a user (for example generating some unique attribute values)
Ok I thought and just tried looking at "/users" and only changetype="updated". I created a subscription and an basic Azure function to handle the requests. Updated a user in Azure AD (just changed "Last name" attribute) and sure enough a trigger was sent to my Azure function
Now comes my biggest problems - this is really unusable in its current form.
his seems to react to the all changes /users and i guess the trigger response could contain several users.
It really would be preferable to get individual triggers for each object changed in /users even though they were changed at the same time
Looking at the actual information sent here lies the BIG problem.
I get the id of the user changed (good, but also expected)
I get the organizationId (ok..)
I get the eventTime (good)
I get a sequenceNumber (unsure what this is?)
I get subscriptionExpirationDateTime (ok fine good to have)
I get subscriptionId for the webhook (ok fine good to have)
... but WHERE is information about what data was changed??? Nowhere to be found is what attributes of the user were changed (i my case "Last name"). This makes the triggers totally unusable for "/users" and I cant really think of anyone who could use this function as is?
Sure I know the object was changed but I have no idea WHAT happened and if the change was relevant to my function
Please tell me there are plans to include the actual changes in the trigger response?
EDIT: ok right, yeah this is more a feature request from the actual developers of ms graph - will look for a better place to get this answered
Please provide feature requests here (ex: richer data in notifications, "created" change type) : https://officespdev.uservoice.com/forums/224641-feature-requests-and-feedback?category_id=101632
Here are answers to other questions.
Microsoft graph doesn't guarantee ordering of events when sending notifications (ex: your webhook endpoint could be down and we will retry events delayed by up to 4 hours or drop if the outage is longer than 4 hours). Hence "SequenceNumber" can be used to track if an event is in order and hence used as is or if it is out of order and needs a query to Graph to get current state.
Currently, we provide Ids of objects and associations (member, manager) that have changed, whether the object/associations is deleted or updated but not details of other properties that were changed. In its current form, webhook is best used with delta query. Instead of polling delta query every X minutes and in most cases receiving zero changes, developers can create a subscription and perform delta query only when a notification is received. This would help scale in case there are many tenants that needs to be polled.
Delta Query: https://developer.microsoft.com/en-us/graph/docs/concepts/delta_query_overview
Also FYI, webhook notifications for user/group is now also available in V1.0

Get new emails with microsoft graph

I am trying to get only new emails with microsoft graph.
Iam doing this by checking date like
GET https://graph.microsoft.com/v1.0/me/messages?$filter=receivedDateTime+gt+2016-06-06T08:08:08Z
Is there any possibility to build query to get new messages but base on id instead of receivedDateTime? Something like: get messeges until you find id=....?
I think the delta query solution is pretty good (as suggested in a different answer). However, for my purposes, there were two major drawbacks: 1) it's in preview (beta) right now, so it makes it less than ideal for production code and 2) it doesn't seem to support the monitoring of all messages, just those in a particular folder.
I actually prefer the solution you're working with. The timestamp in the header of the response can be used to reset the time field in you query, so that if you have "receivedDateTime gt 12:00:00" and get back the server time of 12:01:00 for your request, you can use "receivedDateTime gt 12:01:00" next time.
The scenario you're looking for is specifically what the new Delta query is designed to support. Deltas allow you to retrieve changes to a given folder (i.e. Inbox) since you last polled that folder. Message IDs not static or consecutive so they're not a suitable property for determining new vs. old messages.

Resources