0
votes

I have an on-premises SharePoint 2013 with a list. I need to get that list from a client app (not Office/Sharepoint 'App') using the REST API remotely. I don't know how to authenticate against SharePoint. I don't want to use access tokens or form based authentication. Security certificates don't work either because it's not a 'SharePoint App'. Can somebody help me? Thanks.

1

1 Answers

1
votes

I found out the solution, it turns out it's very simple.

 string url = "http://<siteUrl>/_api/web/lists";
 HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
 webRequest.AuthenticationLevel = System.Net.Security.AuthenticationLevel.MutualAuthRequested;
 webRequest.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
 webRequest.Method = "GET";
 Stream response = webRequest.GetResponse().GetResponseStream();
 StreamReader reader = new StreamReader(response);

That code brings whatever lists your site contains, and puts the result into the stream reader. I was looking for something too complex when it turned out it was quite simple. Hope it helps someone!