0

I'm attempting to retrieve the details of a SharePoint list using the following:

using (var ctx = new ClientContext("http://sharepoint/ci"))
{
    var list = ctx.Web.GetList("/ci/resources/Lists/Resource%20Orders/");

    ctx.Load(list);
    ctx.ExecuteQuery();
}

When I execute this I'm receiving an unhandled ServerException with the details:

An unhandled exception of type 'Microsoft.SharePoint.Client.ServerException' occurred in Microsoft.SharePoint.Client.Runtime.dll

The Microsoft.SharePoint.Client.dll I'm using was fetched using Nuget so I believe it's possible that it's not the same version as the one on my clients server (as web.GetList() wasn't added until the March 2015 cumulative update).

Am I doing something else wrong or should I be going back to our server team and asking them to bring the servers cumulative updates up to date?

  • Try Loading the Web Object before making Call on it : "ctx.Site.Web" – Arvi Aug 5 '15 at 2:14
  • @MpArvind That doesn't make any sense syntactically? This same code works with SPO also. – Michael A Aug 5 '15 at 3:37
  • Try using ctx.Web.Lists.GetByTitle("ListTitle") instead. – Akhoy Aug 5 '15 at 4:46
  • @uberz91 That doesn't appear to exist within this namespace or context – Michael A Aug 5 '15 at 5:45
  • Weird... msdn.microsoft.com/library/office/… – Akhoy Aug 5 '15 at 5:51
0

Credit to @uberz91 for the answer to this one. It appears I was using getlist() incorrectly and instead need to use web.Lists.GetByTitle() (documentation):

using (var ctx = new ClientContext("http//sharepoint"))
{
      var list = ctx.Web.Lists.GetByTitle("Resource Order Form Content");

      ctx.Load(list);
      ctx.ExecuteQuery();
}
  • GetList() method is available only on SP version>=15.0.4701.1001. Source – nbi Nov 9 '15 at 11:36
-1
var clientContext=new SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle("AdaptorImages");// Get List
var camlQuery = SP.CamlQuery.createAllItemsQuery();

this.frontPictureItems = oList.getItems(camlQuery);
clientContext.load(frontPictureItems, "Include(Id, DisplayName, FileLeafRef,EncodedAbsUrl)");

Refer this for more info

https://codeplayandlearn.wordpress.com/2015/08/04/content-editor-webpart-slider-using-adaptor-slidercsom/

  • This doesn't appear to relate to the question at all... – Michael A Aug 6 '15 at 2:26

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.