question

SamChengTataConsultancyServicesLtd-4674 avatar image
0 Votes"
SamChengTataConsultancyServicesLtd-4674 asked ·

Exchange Web Service - The remote server returned an error: (401) Unauthorized

I am trying to connect to Exchange Web Service by using email and pwd:

var exchangeService = new ExchangeService()
{
//credentials.UserName
Credentials = new WebCredentials(credentials.EmailAddress, credentials.Password),
Timeout = 60000
};

         // Set the URL.
         exchangeService.Url = new Uri("https://computername.domain.contoso.com/EWS/Exchange.asmx");
         Logger.DebugFormat("Service URL: {0}", exchangeService.Url);

         return new EWSConnection()
         {
             Service = exchangeService,
             Router =
                 new RecipientsMailboxManagerRouter(
                     new EWSMailFolder(Folder.Bind(exchangeService, WellKnownFolderName.Inbox), useConversationGuidOnly))
         };

And I got the remote server returned an error: (401) Unauthorized.
It used to be working fine but just last Friday, I got this issue. Can anyone help me please?

not-supported
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ManuPhilip avatar image
0 Votes"
ManuPhilip answered ·

Hello,

Various exchange services can be tested with online testconnectivity tool from Microsoft. You may test the EWS connectivity as follows and see it works. If not adjust the code or server settings. If you need further support, please paste the test result here:

  1. Open https://testconnectivity.microsoft.com.

  2. Select Office 365 or Exchange Server as per your setup.

  3. Select Service Account Access and perform Test. Use the same parameters you use in code

Thanks,
Manu

· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello,

I'm also experiencing the same issue using the shared mailbox email address

I'm not sure how to check for MFA or SSO so I'm not sure how am I able to do that so if you have instructions on how, please guide me

99706-ews-401-error.png


0 Votes 0 ·
ews-401-error.png (130.2 KiB)
SamChengTataConsultancyServicesLtd-4674 avatar image
0 Votes"
SamChengTataConsultancyServicesLtd-4674 answered ·

Thank for the tool! I have been looking for something like this to test the connection.

Here is the Exchange Web Services URL, https://outlook.office365.com/EWS/Exchange.asmx, that I am trying to access to.
Unfortunately, I got the same issue.

8356-ews-unauthorized.png



· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @SamChengTataConsultancyServicesLtd-4674

Could you please check if MFA or SSO is enabled for the mailbox you try to test. If so, disable those features and try a test

Thanks,
Manu


0 Votes 0 ·