I need to read list data from SharePoint 2019 on-premise server, from an external server. I have tried calling the REST API but I am having trouble authenticating.
Things I have tried:
Calling REST endpoint with Network Credentials:
var client = new RestClient(url); var request = new RestRequest(Method.GET) { Credentials = new NetworkCredential("username", "password", "domain") }; var response = client.Execute(request); return response.Content;
I am getting 403 response in this case.
I was successful with a cookie I obtained when accessing the site from the browser (this is not a solution):
var client = new RestClient(url); var request = new RestRequest(Method.GET); request.AddHeader("Cookie", "cookie-value"); return response.Content;
What kind of authentication is needed to perform calls to SharePoint REST API? I have also looked up custom Add-Ins, but can only find documentation for SharePoint Online.