You could use this way to call rest api and you could use DefaultCredentials to authenticate.
HttpWebRequest endpointRequest = (HttpWebRequest)HttpWebRequest.Create("http://sp/_layouts/15/listfeed.aspx?List=%7B42925B98-CBD0-41F8-B0F5-6D4D85B0A21C%7D");
endpointRequest.Method = "GET";
endpointRequest.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");
endpointRequest.Credentials = System.Net.CredentialCache.DefaultCredentials;
HttpWebResponse endpointResponse = (HttpWebResponse)endpointRequest.GetResponse();
try
{
WebResponse webResponse = endpointRequest.GetResponse();
Stream webStream = webResponse.GetResponseStream();
StreamReader responseReader = new StreamReader(webStream);
string response = responseReader.ReadToEnd();//results
responseReader.Close();
Console.WriteLine(response);
Console.ReadLine();
}
catch (Exception e)
{
Console.Out.WriteLine(e.Message); Console.ReadLine();
}
Test result:
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.