0

I'm trying to download windows SharePoint services site list using client side object. I'm getting error 500 error site does not exist.How can I download list data from windows SharePoint services

  • sharepoint version?how you trying to download it? – Waqas Sarwar MVP Apr 24 '15 at 14:28
  • pls, check your ULS logs and post the result – Nk SP Apr 24 '15 at 17:39
  • url is correct ,the same code is working for one url (i.e site collection is in SharePoint farm).This site is windows SharePoint services site.Is this is the problem, I'm new to SharePoint services. Both the sites is same. – sindura Apr 25 '15 at 6:39
0

Lists are a part of SPWeb not SPSite. Once you have the correct web, it's pretty easy to extract the list from the web.

ClientContext context = new ClientContext(webUrl);
context.Credentials = new NetworkCredential("user", "password", "domain");
targetWeb = context.Web;
targetList = targetWeb.GetList("http://server/listUrl");
context.Load(targetList);
context.ExecuteQuery();
foreach(var item in targetList.Items)
{
    string title = item.Title;
    var fieldOne = item["myCustomField"]
    var fieldTwo = item["anotherField"]
    // save the list item
}

Once you start iterating through the items in the list, you will need to pass in the field (i.e. column) name to get the data out. You can also use the Fields property on the list to figure out what columns are dynamically.

| improve this answer | |
  • I'm using the below code, but I'm getting site didn't find. Is there any problem if site is windows SharePoint service ClientContext context = new ClientContext(Url); targetWeb = context.Web; targetList = targetWeb.GetList("server/listUrl"); context.Load(targetList); context.ExecuteQuery(); foreach(var item in targetList.Items) { string title = item.Title; var fieldOne = item["myCustomField"] var fieldTwo = item["anotherField"] // save the list item } I'm new to sharePoint,please help. – sindura Apr 25 '15 at 8:42
  • You can look at the TraceCorrelationId property on the context object. From there, you can use the ULS Viewer to find the server side trace and filter it down by the correlation id. Can you also post the exact error you are getting in the question? – Zach Apr 25 '15 at 18:58
  • error :An unhandled exception of type 'System.Net.WebException' occurred in Microsoft.SharePoint.Client.dll Additional information: The remote server returned an error: (500) Internal Server Error.(This error I'm getting context.ExecuteQuery(); line) – sindura Apr 27 '15 at 5:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.