The issue that triggers a 400 Bad request in Form or Console applications in Visual Studio can often be the choice of Framework.
VS default console application framework is .net core and Microsoft.SharePoint.Client doesn’t work with it.
The correct choice should be one of the .net framework versions.
The ClientCode that gives the 400 Bad request error looks like:
ClientContext clientContext = new ClientContext(url); clientContext.Credentials = getCredentials(); clientContext.ExecuteQuery(); List docLib = clientContext.Web.Lists.GetByTitle("TestLib"); clientContext.Load(docLib); clientContext.ExecuteQuery();