Access denied error when trying to move a specific message through the microsoft Mail API v1.0

jonas 6 Reputation points
2022-10-13T09:56:24.96+00:00

Hey,

I have a question regarding some strange behaviour when calling the microsoft graph api to move emails from the "inbox" folder to the "recoverableitemspurges" folder.

For our mailbox in question, we are moving emails into the "recoverableitemspurges" folder once they are fully processed by our system.
We do this by calling the graph api endpoint "/users/{userId}/messages/{messageId}/move" with destinationId = "recoverableitemspurges".

This is working correctly for all emails in the mailbox except for one.

For email with id "AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0AQf_jhhXIfUOUBNR80F6p8QADXE1jbQAA", we get an error with:
Error code: ErrorAccessDenied
Error message: Access is denied. Check credentials and try again., The store ID provided isn't an ID of an item.

The email is no longer visible when we look directly in the mailbox.

This behaviour is quit strange since we are using the correct credentials for our app/mailbox and have no problem moving other emails for the mailbox.

Furthermore we expect that if the email can not be found for the mailbox, we get an error with:
Error code: ErrorItemNotFound
Error message: The specified object was not found in the store., The store ID provided isn't an ID of an item.

Could you explain why we do not get an "ErrorItemNotFound" error for the failing email id?

Thanks for the help!

Microsoft Security Microsoft Graph
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Walisson Dias 316 Reputation points
    2022-10-13T12:25:51.677+00:00

    Hi @jonas ,

    Does this particular mailbox have any retention policies applied? Or do you have Archive Mailbox enabled?

    As you can see in the documentation below, when a message is moved, the ID changes and there may be a delay in changing to the correct ID.

    https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/ews-identifiers-in-exchange#working-with-identifiers

    https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/deleting-items-by-using-ews-in-exchange

    And here shows a different scenario, but the same symptom.

    https://learn.microsoft.com/en-us/outlook/troubleshoot/performance/erroritemnotfound-when-office-add-ins-make-rest-calls

    Hope this helps.

    WD

    ==
    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.