The request failed. The remote server returned an error: (401) Unauthorized.

Odene Gerber 0 Reputation points
2023-10-26T07:04:38.6333333+00:00

Hi,

Trying to connect to the EWS - The request failed. The remote server returned an error: (401) Unauthorized. - is the error message.

Using the TestConnectivity test, the error is the below code.

My problem is, my mails are hosted with Office itself and I cannot seem to find a solution.

Exchange Online
Exchange Online
A Microsoft email and calendaring hosted service.
6,188 questions
Exchange | Exchange Server | Other
Exchange | Exchange Server | Development
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Amit Singh 5,306 Reputation points
    2023-10-31T03:47:47.21+00:00

    Try to disable MFA and check.

    Basic authentication in now disabled by default in Office 365, so you should avoid using it. Look at implementing oAuth in your see code https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-authenticate-an-ews-application-by-using-oauth

    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.