I recently had a question and how to connect to the REST web api using c# and it gave a hard time trying to connect, documentation does not give any clue how to use the rest web api(code) but community forums does, but in the code there is a CSOM nugget that seems to handle the negotiation when requests are made code below.
var s = new System.Security.SecureString(); "123abc".ToList().ForEach(o => s.AppendChar(o)); SharePointOnlineCredentials cred = new SharePointOnlineCredentials("firstname.lastname@example.org", s); HttpWebRequest endpointRequesta = (HttpWebRequest)HttpWebRequest.Create("https://test.sharepoint.com/sites/CRM/_api/contextinfo"); endpointRequest.Method = "GET"; endpointRequest.Accept = "application/json;odata=verbose"; endpointRequest.Credentials = cred; //<-- Notice this endpointRequest.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f"); HttpWebResponse endpointResponse1 = (HttpWebResponse)endpointRequest.GetResponse();
my questions are
Here it's using SharePointOnlineCredentials Object from CSOM ¿Why can't I use System.Net.NetworkCredential("email@example.com", "123abc")(basic Auth)? well I can use it but it raise an error 401 but with SharePointOnlineCredentials runs well. but ¿why?
So it make me think then that I'm forced to use .net or C# for calling this sharepoint REST Apis ¿What if i just need to call this rest api as normal webservice with any languaje?