8
Answers

Retriving list items using dotnet csom In sharepoint

Cibun Swain

Cibun Swain

10y
1.5k
1
  Hi ,,
 
 Currently i am running with a issue that is..i want to retrieve sharepoint  list items by using dotnet csom..but it throwing 404 unautherized error.
after giving system account credential also throwing same error..please anybosy help me out where i am going wrong
 Below is my code
 
// ClientContext context = new ClientContext(HttpContext.Current.Request.Url);
using (ClientContext context = new ClientContext("http://najbsys2:16786/Holidays"))
{
context.Credentials = new NetworkCredential("naspadmin01", "Hello#!@#", "DC");   //naspadmin01(system account/Application pool admin)
List getitems = context.Web.Lists.GetByTitle("Expenses");
CamlQuery query = CamlQuery.CreateAllItemsQuery(100);Expenses
ListItemCollection items = getitems.GetByQuerry(querry);
context.Load(items);
context.ExecuteQuery();
foreach (var item in items)
{

lblUrl.Text = item[""EmpNumber].ToString();
lblUrl.Text += Environment.NewLine;
}
}
  please any body has any solution provide me

Answers (8)