An API that connects multiple Microsoft services, enabling data access and automation across platforms
Microsoft Graph API /messages returns incomplete JSON
I am syncing emails with a third-party application. I try to retrieve up to 100 emails at a time where the lastModifiedDateTime is within a one-week span. Most requests complete without any issues. If a request fails, I retry it with $top=10. If that fails, I retry it with $top=1. This very rarely fails. However, if it does, then I add one second to the minimum lastModifiedDateTime in my date range, and I exponentially add more time to the minimum lastModifiedDateTime each time it fails. The idea is that there is one or more emails that I cannot retrieve -- I don't know which ones -- and I must skip past them to recover. This has worked well for a few years.
There are some mailboxes that have gotten stuck recently. Instead of a 5xx error, or even a client-side timeout, the API responds with a 200 OK and begins to return JSON. However, the JSON is just some variation of this:
{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users('<user_id>')/messages(bccRecipients,categories,ccRecipients,changeKey,conversationId,conversationIndex,createdDateTime,flag,from,hasAttachments,id,importance,inferenceClassification,internetMessageId,isDeliveryReceiptRequested,isRead,isReadReceiptRequested,lastModifiedDateTime,parentFolderId,receivedDateTime,replyTo,sender,sentDateTime,subject,toRecipients,webLink)","value":[
It ends with "value":[ every time. This occurs no matter the $top size. Out of three mailboxes, two of them were able to recover once they skipped past the email that was causing the problem. But there is still one that seems incapable of recovering. It is now trying to skip over one month of emails, but has not succeeded yet. The incomplete JSON is still returned every time.
Here are the Request-IDs for several such requests:
-
64f4a9d7-01a3-432e-b132-ca6c6d52fb95 -
1b944cf9-4d50-4a01-b806-20643f761652 -
ddc29790-e229-4fb2-a20a-0f7bc235f88b -
8bba410c-7206-4724-99ee-c4e7df35f826
Can you tell me why these requests are failing?
For the two mailboxes that eventually succeeded, here are the Request IDs for two failing requests. Can you tell me why those requests failed?
- Request-ID for mailbox A:
044718e9-d2ee-47d7-8ec9-78e865ad9930 - Request-ID for mailbox B:
a969c5f0-8ea5-4029-953a-90122fe944d2