I would like to develop a page to get the list data from SharePoint 2013(Office 365)
I try to get the data from REST API e.g.
String url="https://siteurl/_api/web/GetFolderByServerRelativeUrl('Photo')/files" WebRequest request = WebRequest.Create(url); request.Credentials = new NetworkCredential(username, password); request.ContentType = "application/json; charset=UTF-8"; WebResponse response = request.GetResponse(); Stream stream = response.GetResponseStream(); System.IO.StreamReader streamReader = new System.IO.StreamReader(stream, Encoding.UTF8); string strOut = streamReader.ReadToEnd();
It will return the 403 error.
After my finding, I think I'm missing the access token, and the access token should be get from the SharePoint apps.
Anyone can tell me how can I get the access token.?
Is it mean I should create high trust app first, and let the page to call the app to get the access token??
Please let me know if the logic is wrong.