I have this annoying issue when trying to connect to SharePoint site using Microsoft.SharePoint.Client
:
var url = "https://company.sharepoint.com/sites/ADV-DEV/assigDev/bassie/SitePages/Home";
var clientContext = new ClientContext(url);
var oWebsite = clientContext.Web;
clientContext.Load(oWebsite);
clientContext.ExecuteQuery();
Console.WriteLine("Title: {0} Created: {1}", oWebsite.Title, oWebsite.Created);
On the line
clientContext.ExecuteQuery();
I just get
System.Net.WebException: 'The remote server returned an error: (400) Bad Request.'
Even though that site definitely exists.
I tried removing each of the items from the url all the way down to just https://company.sharepoint.com
but with the same results.
What is going on? Why is it so difficult just to connect to a SharePoint site?