title: Bad request while trying to access Sharepoint
body: <p>I am trying to access to a <code>Sharepoint site</code> from my WebApp but I get the following error:</p>
  
  <pre><code>An unhandled exception occurred while processing the request.
  WebException: The remote server returned an error: (400) Bad Request.
  System.Net.HttpWebRequest.GetResponse()
  </code></pre>
  
  <p>Info:
  <a href="https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/complete-basic-operations-using-sharepoint-client-library-code" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/complete-basic-operations-using-sharepoint-client-library-code</a></p>
  
  <p>Code:</p>
  
  <pre><code>public void ReadSharepointProperties()
  {
      try
      {
          using (ClientContext context = new ClientContext(_siteURL))
          {
              Web web = context.Web;
              context.Load(web);
              context.ExecuteQuery();
          }
      }
      catch (Exception)
      {
  
          throw;
      }
  }
  </code></pre>
  
  <p><code>_siteURL</code> is correct. At least I can access it.  </p>
  
  <p>Any idea?</p>
  
  <p><strong>.NET core 2.0.5</strong></p>
  
  <p><em>EDIT:</em></p>
  
  <p>More info: I see in the debug the call changes to "url.../_vti_bin/sites.asmx"</p>
  
  <p>I tried to do like in the link <a href="http://rajujoseph.com/getting-net-core-and-sharepoint-csom-play-nice/" rel="nofollow noreferrer">http://rajujoseph.com/getting-net-core-and-sharepoint-csom-play-nice/</a> and now the error is different:</p>
  
  <blockquote>
    <p>One or more errors occurred. (Cannot find platform service library.
    For Windows Store application, please include
    Microsoft.SharePoint.Client.Runtime.WindowsStore.dll in the
    application package. For Windows Phone application, please include
    Microsoft.SharePoint.Client.Runtime.WindowsPhone.dll in the
    application package. For Windows application, please install
    Microsoft.SharePoint.Client.Runtime.Windows.dll in the GAC (Global
    Assembly Cache) or make it available for the Windows application.)</p>
  </blockquote>
  
  <p>Error is clear and the link tells how to solve it, but for console application. This case is for a ASP NET CORE, so it seems the dlls are no valid.</p>