Hi,
I am getting below error when trying to connect to SharePoint Online site using REST API.
An unhandled exception of type 'System.Net.WebException' occurred in System.dll
Additional information: The remote server returned an error: (403) Forbidden.
I am writing this code in Visual studio 2015. Below is my code:
var url = "https://sudheero366.sharepoint.com/POCSite/_api/web";
var client = new WebClient();
//ICredentials credentials = new NetworkCredential(" my username", "my password");
//client.Credentials = credentials;
client.UseDefaultCredentials = true;
var xml = client.DownloadString(url); // I AM GETTING ERROR IN THIS LINE
var doc = XDocument.Parse(xml);
XNamespace ds = "http://schemas.microsoft.com/ado/2007/08/dataservices";
var titles = doc.Descendants(ds + "Title");
var title = titles.First().Value;
ResultsListBox.Items.Add(title);
can some one help me where is it going wrong?
Thanks,
Sudheer.
Thanks, PVSAVSG.