Came across another Clumsy Ninja SharePoint feature recently concerning the ListData.svc REST API which is found in both SharePoint 2010 and 2013.
This issue does not occur if you’re using the new _API REST interface for SharePoint 2013.
The issue concerns the list or library name which you use in a REST call;
ListData.svc REST Call:
Usually when you use a list or library name with ListData.svc, you use the list ‘Title’ and remove spaces from it, so given a list name of ‘My Cool List’ your REST call using ListData.svc would look like so;
And so to the problem
So, lets say you have a list whose title begins with 1 or more digit characters, lets say ‘3 Year Plan’,
Naturally, you create your REST call like this;
You execute your call, but it fails with the following error “Resource not found for the segment ‘3YearPlan'”;
The problem is nothing to do with the list name and everything to do with how SharePoints LINQ
DataServiceDataContext handles list names.
The DataServiceDataContext class is found in assembly
Microsoft.SharePoint.Linq.DataService, Version=22.214.171.124, Culture=neutral, PublicKeyToken=71e9bce111e9429c
The class constructor maps SharePoint list titles in the addressed SPWeb;
Notice the call to
Util.GetFriendlyName(...), its here that ‘friendly’ list names are created from the SharePoint list names and it’s these which are matched against the list name supplied by you in the REST call;
So as you can see, if a SharePoint list name starts with 1 or more digit characters, the letters
"c_" are prepended to the list name.
This means that you need to know (or detect) in advance of making your REST call that a list name is like this, so you can adjust the list name supplied in your REST call accordingly, and when you do, all works as expected;