Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9323283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T04:18:20+00:00 2026-06-19T04:18:20+00:00

We’re programmatically (using the Microsoft Exchange Web Services Managed API 2.0) to access the

  • 0

We’re programmatically (using the Microsoft Exchange Web Services Managed API 2.0) to access the user’s calendar (on Exchange 2010 SP1).

We have been able to successfully communicate with EWS via auto-discovery in our development environment on which we didn’t have to make any specific settings (we used the default out-of-the-box settings) on Exchange.

Unfortunately the same doesn’t work on the client’s environment. The client doesn’t have a test environment. We’re supposed to communicate to their live Exchange server.

Initially auto-discovery didn’t work on the client’s environment. We got the following error:

Microsoft.Exchange.WebServices.Data.AutodiscoverLocalException: The Autodiscover service couldn't be located.
   at Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.InternalGetLegacyUserSettings[TSettings](String emailAddress, List`1 redirectionEmailAddresses, Int32& currentHop)
   at Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.GetLegacyUserSettings[TSettings](String emailAddress)
   at Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.InternalGetLegacyUserSettings(String emailAddress, List`1 requestedSettings)
   at Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.GetUserSettings(String userSmtpAddress, UserSettingName[] userSettingNames)
   at Microsoft.Exchange.WebServices.Data.ExchangeService.GetAutodiscoverUrl(String emailAddress, ExchangeVersion requestedServerVersion, AutodiscoverRedirectionUrlValidationCallback validateRedirectionUrlCallback)
   at Microsoft.Exchange.WebServices.Data.ExchangeService.AutodiscoverUrl(String emailAddress, AutodiscoverRedirectionUrlValidationCallback validateRedirectionUrlCallback)

So now we explicitly specify the URL to the EWS. This gave us the following error:

Microsoft.Exchange.WebServices.Data.ServiceRequestException: The request failed. The remote server returned an error: (401) Unauthorized. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.
       at System.Net.HttpWebRequest.GetResponse()
       at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(HttpWebRequest request)
       --- End of inner exception stack trace ---
       at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(HttpWebRequest request)
       at Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.InternalExecute()
       at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
       at Microsoft.Exchange.WebServices.Data.ExchangeService.BindToFolder(FolderId folderId, PropertySet propertySet)
       at Microsoft.Exchange.WebServices.Data.ExchangeService.BindToFolder[TFolder](FolderId folderId, PropertySet propertySet)
       at Microsoft.Exchange.WebServices.Data.CalendarFolder.Bind(ExchangeService service, FolderId id)

The exception is thrown in line 5 of the following code:

ServicePointManager.ServerCertificateValidationCallback = this.CertificateValidationCallBack;
ExchangeService exchangeWebService = new ExchangeService(ExchangeVersion.Exchange2010_SP1);

exchangeWebService.Credentials = new WebCredentials("username@domain.local", "myPassword");
exchangeWebService.AutodiscoverUrl("username@domain.local", this.RedirectionUrlValidationCallback);

**CalendarFolder calendarFolder = CalendarFolder.Bind(exchangeWebService, new FolderId(WellKnownFolderName.Calendar, userName));**

CalendarView calendarView = new CalendarView(startDate, endDate);
calendarView.PropertySet = new PropertySet(BasePropertySet.IdOnly, AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.IsRecurring, AppointmentSchema.AppointmentType, AppointmentSchema.End, AppointmentSchema.Duration);

FindItemsResults<Appointment> findResults = calendarFolder.FindAppointments(calendarView);

We don’t mind that auto-discovery doesn’t work since we can explicitly specify the URL to the EWS. What we would like to know are what settings, permissions etc. we need to check on the client’s instance of Exchange to determine why the above exception (ServiceRequestException) is being thrown.

We have requested the following commands to be executed on the Exchange Management Shell on the client’s instance of Exchange:

Test-OutlookWebServices –Identity username
Get-OrganizationConfig

We are yet to receive the results. Please let us know if there is anything else we should check.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T04:18:21+00:00Added an answer on June 19, 2026 at 4:18 am

    We knew that the client had a proxy address. What we didn’t know is that we needed to use the domain address (username@domain.local) when authenticating with EWS and the proxy address (username@domain.com) when invoking AutodiscoverUrl and when accessing the mailbox.

    So the above code should be:

    ServicePointManager.ServerCertificateValidationCallback = this.CertificateValidationCallBack;
    ExchangeService exchangeWebService = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
    
    exchangeWebService.Credentials = new WebCredentials("username@domain.local", "myPassword");
    exchangeWebService.AutodiscoverUrl("username@domain.com", this.RedirectionUrlValidationCallback);
    
    CalendarFolder calendarFolder = CalendarFolder.Bind(exchangeWebService, new FolderId(WellKnownFolderName.Calendar, "username@domain.com"));
    

    We were using either the domain address or the proxy address. We never tried the above combination, until we accidentally forgot to change the one on line #3 of the above code. 🙂

    Thank you, to everyone that viewed the question and tried to answer it. I hope this will help someone someday.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to programmatically remove rows from a Microsoft Access Database using a
I am trying to access an SQLite 3 database programmatically using the code below:
I have my ipad code created programmatically not using nib.I converted my ipad app
The following web page describes querying Windows Search programmatically: http://msdn.microsoft.com/en-us/library/aa965362.aspx Does anyone have examples
I've been working on a process for programmatically generating Visual Studio projects using GetProjectTemplate.
I'm using the new Microsoft ASP.NET Ajax ComboBox control in my web application, and
Question I want to programmatically open a RTF file in Microsoft Word using C#.
I'm trying to programmatically create a timeline and markers using the Visio 2010 COM
I am using Microsoft's CDO (Collaboration Data Objects) to programmatically read mail from an
I have found several samples about retrieving test results using the TFS API, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.