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

SharePoint Server
SharePoint Server
A family of Microsoft on-premises document management and storage systems.
2,395 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,133 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,626 questions
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 36,821 Reputation points Microsoft Vendor
    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.



Your answer

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