Forum Discussion
please help with : The response received from the service didn't contain valid XM error
Hi Eddy-2023,
The error message you're encountering, "(401) Unauthorized," indicates that there is an issue with the authentication and authorization when your application is trying to access Office 365 services.
The "The response received from the service didn't contain valid XML" error suggests there might also be a problem with the response from the server.
Here are some steps to help you troubleshoot and resolve the issue:
1. Check Office 365 Credentials:
- Ensure that the email address and password you are using in your code are correct and have the necessary permissions to send emails on behalf of the specified account.
2. Use Autodiscover:
- Instead of hardcoding the URL, you can use Autodiscover to automatically discover the correct EWS endpoint URL. This is a more flexible and recommended approach.
service.AutodiscoverUrl("****email address removed for privacy reasons****");
Make sure your code uses the correct Autodiscover method.
3. Service Permissions:
- Verify that the account you're using to authenticate has the necessary permissions to access and send emails through the EWS. You might need to grant ApplicationImpersonation permissions.
4. Check if 2FA is disabled:
- Ensure that two-factor authentication (2FA) is disabled for the account you are using in your application. You mentioned that you've turned it off, but double-check to confirm.
5. Delegations and Permissions:
- Ensure that the permissions and delegations are set up correctly in Office 365 for the sending account.
6. URL and Endpoints:
- The URL you're using should point to the correct EWS endpoint. If Autodiscover doesn't work for some reason, try using a URL like: https://outlook.office365.com/EWS/Exchange.asmx.
7. Firewall and Network Issues:
- Make sure that there are no firewall or network-related issues that might be blocking outgoing requests from your server to Office 365 services. Verify that the server can reach the necessary endpoints.
8. Server Configuration:
- Check your Windows Server IIS configuration to ensure it's not blocking outbound requests to the Office 365 service. Make sure that the URL you are trying to access is not restricted by any URL filtering or proxy settings.
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.
If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic
(LinkedIn)