I am making a request to the Microsoft Graph API to retrieve all emails that have been modified since a particular date. The request is the below:
https://graph.microsoft.com/v1.0/users/59687355-748d-4d9c-aa4c-d0c1d2086eff/messages/?$select=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&$filter=lastModifiedDateTime gt 2022-10-07T10:49:27Z and lastModifiedDateTime lt 2022-10-14T10:49:27Z and isDraft eq false and parentFolderId ne 'conversationhistory' and parentFolderId ne 'junkemail' and parentFolderId ne 'outbox' and parentFolderId ne 'recoverableitemsdeletions' and parentFolderId ne 'scheduled' and parentFolderId ne 'searchfolders'&$orderby=lastModifiedDateTime asc&$top=100
Most of the time it is successful. But sometimes the response is malformed:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('59687355-748d-4d9c-aa4c-d0c1d2086eff')/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": [
{
"@odata.etag": "W/\"CQAAABYAAABsk7XI0Ba5RLTZiPmnkZbZAAFYXkB3\"",
"id": "AAMkADg5NjZhMjkzLWIyODQtNDFkNy1hOWMzLTBhODVlZGFjMGIyMQBGAAAAAADk-kLFG1rtR5MSTyO-jKygBwBsk7XI0Ba5RLTZiPmnkZbZAAAAAAEJAABsk7XI0Ba5RLTZiPmnkZbZAAFZu3S4AAA=",
...
},
{
"@odata.etag": "W/\"CQAAABYAAABsk7XI0Ba5RLTZiPmnkZbZAAFYXkCB\"",
"id": "AAMkADg5NjZhMjkzLWIyODQtNDFkNy1hOWMzLTBhODVlZGFjMGIyMQBGAAAAAADk-kLFG1rtR5MSTyO-jKygBwBsk7XI0Ba5RLTZiPmnkZbZAAAAAAEKAABsk7XI0Ba5RLTZiPmnkZbZAAFZuvoVAAA=",
...
},
{
"@odata.etag": "W/\"CQAAABYAAABsk7XI0Ba5RLTZiPmnkZbZAAFYXkCJ\"",
"id": "AAMkADg5NjZhMjkzLWIyODQtNDFkNy1hOWMzLTBhODVlZGFjMGIyMQBGAAAAAADk-kLFG1rtR5MSTyO-jKygBwBsk7XI0Ba5RLTZiPmnkZbZAAAAAAEKAABsk7XI0Ba5RLTZiPmnkZbZAAFZuvoWAAA=",
...
} {
"error": {
"code": "ErrorItemNotFound",
"message": "The specified object was not found in the store., The process failed to get the correct properties."
}
}
Retrying the request usually works. But the mix of a successful list response with the ErrorItemNotFound
error seems like a Microsoft Graph API bug.
A possible explanation for the bug: The Graph API has retrieved a list of IDs matching the query. It then retrieves each record to assemble the response. Due to mutable IDs the email cannot be found. The error is appended to the response and the response is returned. Maybe the error should have been returned on its own to indicate that the request should be retried. Or maybe this error should be ignored and the rest of the list can be generated and returned.