Hi to all ,
In auto-hosted apps i added custom list without code using feature ,now i deploy that apps in online sharepoint site 2013. Now i want to fetch item from that list using CSOM in Clienthost web part than i got the error and error is
System.Net.WebException: The remote server returned an error: (403) Forbidden. at System.Net.HttpWebRequest.GetResponse() and following code i am using for fetching the data from list
ClientContext clientContext = new ClientContext("https://snapchamp-d4fb71a65ae947.sharepoint.com/");Web web = clientContext.Web;
List list = web.Lists.GetByTitle("TOD");
CamlQuery query = CamlQuery.CreateAllItemsQuery();
Microsoft.SharePoint.Client.ListItemCollection itemcoll = list.GetItems(query);
clientContext.Load(itemcoll);
clientContext.ExecuteQuery();
foreach (Microsoft.Sahrepoint.client.ListItem item in itemColl)
{
// Display the item title field value
Label1.Text = item["Title"].ToString();
}