Share via

SharePoint 2016 On-Premise Rest API

Suresh S 96 Reputation points
2022-09-14T05:38:53.01+00:00

Hi All,

How to use SharePoint On-Premise Rest API to authenticate and get the documents list from the folder? Is this feasible? Please provide your thoughts.

Thanks
Sankaran

Microsoft 365 and Office | SharePoint Server | For business
Microsoft 365 and Office | SharePoint | Development
Microsoft 365 and Office | SharePoint Server | Development

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,496 Reputation points Microsoft External Staff
    2022-09-15T01:40:12.4+00:00

    Hi @Suresh S
    You could use this way to call rest api and you could use DefaultCredentials to authenticate.

     string url = "http://sp/_api/web/getfolderbyserverrelativeurl('/Document/Folder1')/files?$expand=ListItemAllFields";  
     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);  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    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.


    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.