Home > DEV, Infrastructure > Access to an external Sharepoint List with Sharepoint Client API

Access to an external Sharepoint List with Sharepoint Client API

Do you need to access a Sharepoint List from a NonSharepoint Application???! With Sharepoint 2010 it is extremely easy… you can benefit of the Sharepoint Client API and it would be extremely easy to control resource hosted on SharePoint external list.
Obviously, whenever it is possible, I would suggest to cache the Sharepoint List in your application cache layer to avoid performance issues….

 public static ListItemCollection GetClientList(string listPath)
  string url = ConfigurationManager.AppSettings["sharepointConfigSite"];
  using (Microsoft.SharePoint.Client.ClientContext ctx = new Microsoft.SharePoint.Client.ClientContext(url))
        var list = ctx.Web.Lists.GetByTitle(listPath);
       CamlQuery camlQuery = new CamlQuery();
       camlQuery.ViewXml = "<View/>";
       ListItemCollection listItems = list.GetItems(camlQuery);
        if (ConfigurationManager.AppSettings["sharepointUserConfigSite"] != null)
           string username = ConfigurationManager.AppSettings["sharepointUserConfigSite"];
           string pwd = ConfigurationManager.AppSettings["sharepointPwdConfigSite"];
            string domain = ConfigurationManager.AppSettings["sharepointDomConfigSite"];
            var cred = new System.Net.NetworkCredential(username, pwd, domain);
            ctx.Credentials = cred;
           }   else  {
                    ctx.AuthenticationMode = ClientAuthenticationMode.Anonymous;
            return listItems;
Categories: DEV, Infrastructure Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: