Zum Inhalt springen

Syncing Outlook Messages? Beware of This Delta Link Issue in Power Automate

When you want to sync anything accessible via Graph API, delta queries can be a great tool. Instead of relying on individual triggers (“Each time a message arrives”) or a time-based filter (“Return all messages received in the last 24 hours”), you can just call a delta link that returns both the data you’re asking for and a new delta link for the next time you want to sync. This ensures you get all new items that have been created in the meantime, whether you call the link 5 minutes or 5 days later.

So when I recently had the requirement to sync Outlook mail attachments from emails in a specific folder to SharePoint, delta links called via a Power Automate Flow with a time-based repeating trigger seemed like a great idea. Using delta links saved me from having to compare individual IDs as a filter or using a time-based filter, which may run into issues if your flow is ever turned off or the connection breaks. There’s even a “Send an HTTP request” action in the Office 365 Outlook connector, meaning there’s no need to mess around with the “HTTP with Microsoft Entra ID (preauthorized)” connector, which is a bit more complicated to set up. Easy!

Or so I thought.

When delta links get weird

The first call works exactly as expected:

You get your messages and a delta link for the next sync1. But when you actually try to use that delta link in Power Automate, things start to fall apart.

Instead of a nice, clean URL, the @odata.deltaLink returned by Graph looks something like this:

https://graph.microsoft.com/v1.0/me/mailFolders('AAMkAGNjMj...')/messages/delta?$deltatoken=...

The folder ID is suddenly wrapped in parentheses and single quotes. Power Automate refuses to accept it when you try to use this link, returning this error:

URI path is not a valid Graph endpoint, path is neither absolute nor relative or resource/object is not supported for this connector.

Funny (and exasperating) thing: the link works in the Graph API Explorer without any issues.

Fixing the delta link mess

Turns out, Power Automate expects the URL in the same format as the original request:

https://graph.microsoft.com/v1.0/me/mailFolders/folderId/messages/delta?$deltatoken=...

No parentheses, no single quotes. Just the folder ID and the delta token.

The fix? Instead of saving the delta link in full for the next call (I saved it in a hidden Sharepoint column), get the query part of the returned URL which includes the delta token. You can easily do it with this expression in a Compose action:

uriQuery(body('Send_first_Delta_request')?['@odata.deltaLink'])

This returns something like "?$deltatoken=LztZwWjo5Iiv...", which you can simply append to the URL you successfully used for your first request.

Final thoughts

This was a weird one. I’m not sure what is going on behind the scenes here to make it work in Graph Explorer (and my browser) and messed around quite a bit with different links, encodings and so on. The solution I provided here should still keep working if Microsoft ever changes the return format to the one we actually need, so that’s a plus 🙂

  1. It may also be a nextLink, if there have been more changes than can be returned in one call. Just wrap the action in a “Do Until” loop and call nextLinks until the call returns a deltaLink. ↩︎

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

de_DEGerman