title: Exchange Web Services - The response received from the service didn't contain valid XML
body: <p>I am attempting to connect to exchange web services (ews) on a exchange 2010 server. Here is the code I am using:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Text;
  using Microsoft.Exchange.WebServices.Data;
  
  namespace NDR_Processor
  {
      class Program
  {
      static void Main(string[] args)
      {
          ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
          service.Credentials = new System.Net.NetworkCredential("redacted", "redacted", "redacted");
  
          service.Url = new Uri("https://exchange.redacted.net/EWS/Exchange.asmx");
  
          System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
  
          FindItemsResults&lt;Item&gt; findResults = service.FindItems(WellKnownFolderName.Inbox, new ItemView(1000));
  
          foreach (Item item in findResults.Items)
          {
              Console.WriteLine(item.Subject);
              Console.WriteLine(item.Body);
  
          }
      }
  }
  }
  </code></pre>
  
  <p>However in doing so I get an error stating "The response received from the service didn't contain valid XML.". The inner exception indicates: {"Data at the root level is invalid. Line 1, position 1."}</p>
  
  <p>I've tried hitting <a href="https://exchange.redacted.net/EWS/Exchange.asmx" rel="noreferrer">https://exchange.redacted.net/EWS/Exchange.asmx</a> in a web browser, it prompts me to login and then I am presented with a valid XML document as far as I can tell. So I am at a loss as to why my application is choking.</p>
  
  <p>Does anyone have any ideas for why this might be happening or how I can solve it?</p>
  
  <p>Thanks
  Brad</p>