operations fail with an intermittent 500 Internal Server Error

Hamed Amadli, Kasmir 20 Reputation points
2025-09-10T13:14:41.4233333+00:00

We’re developing a custom service account integration with Exchange Online to send and archive messages on behalf of project mailboxes. The app is registered in Azure AD with EWS.AccessAsUser.All and Mail.ReadWrite application permissions, and global admin consent has already been granted.

When attempting to call the EWS endpoint (https://outlook.office365.com/EWS/Exchange.asmx) using OAuth tokens acquired via the client credentials flow, certain operations fail with an intermittent 500 Internal Server Error

Observations:

  • Token decoding shows valid scopes and expiration.
  • Simple operations (e.g., GetFolder, FindItem) succeed consistently, but more complex calls like CreateItem with attachments >5MB trigger the 500 error.
  • The same request sometimes succeeds on retry, suggesting a throttling or backend instability issue.
  • Graph API endpoints (/users/{id}/messages) work with the same token, but lack parity for all EWS functionality we require.
  • Conditional Access policies are not blocking the service principal.

Are there recommended workarounds

Exchange | Exchange Server | Development
0 comments No comments
{count} votes

Accepted answer
  1. Steven-N 7,820 Reputation points Microsoft External Staff Moderator
    2025-09-10T13:58:36.5733333+00:00

    Hi Hamed Amadli, Kasmir

    Thanks for reaching out to Microsoft Q&A forum support

    As far as I know, this issue appears to stem from backend instability or throttling behavior within Exchange Online’s EWS infrastructure. Although the token and permissions are correctly configured, large payloads or complex operations may trigger transient failures due to internal service limits or resource contention. The fact that retries sometimes succeed suggests that the error is not due to misconfiguration but rather environmental factors such as backend load or throttling thresholds.

    As I am forum moderator, due to the limitation of licenses and capability, I can't give you the definitive solution for this. However, I think you can try to follow this instruction to see if the issue still persist: Retry pattern - Azure Architecture Center | Microsoft Learn  

    This summary is based on my findings from the community and several relevant threads. However, it may not accurately reflect the behavior in question. To help you reach your goal more effectively, I recommend posting a thread on the Microsoft Tech Community forum. It’s a great platform for deeper technical discussions and connecting with individuals who have hands-on experience and expertise. They’re best positioned to provide guidance and valuable insights on this topic.    

    Apologies for redirecting you to the related development team support as the moderators in this community have limited resources to check the backend information, and to get the fast and better assistance we requested for it.   

    Hope my answer will help you, for any further support, let me know in the comment section
    Best regards.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".     

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

     

    0 comments No comments

0 additional answers

Sort by: Most helpful

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.