SharePoint 2010 REST API

Posted by Nadeem Yousuf | 02:05 | , | 0 comments »

For past few days I  have been working on a project which makes use of SharePoint REST API for filtering data from lists. I will like to share my findings here.
Let's create a custom list named "Company" as shown:
Now Go to List Settings- General Settings- Title description and navigation and change the name of the list from Company to Company Employees. Make sure to have space between Company and Employees.
Now, the name of the List is Company Employees and the url of the list contains Company only as can be seen:
Before, I show the actual REST queries let us add a text based column named "Employee Address" to the list.
The list with some sample data looks like this:
Now, almost all the examples I found showed the following way of making queries:
http://myserver/_vti_bin/ListData.svc/ListName/

So my first attempt was to use the name of the list which is Company Employees and to my surprise I got the 404 error.

Then I tried "Company"  as the url contained  Company only and got the same error. After that I found the GUID of the list and tried that, and again got the same error. I was losing patience and searched everywhere and could not get any useful information. Finally, I removed the space between Company and Employees and tried again and viola I got the results.
Similarly, if we try to filter using "Employee Address" column, it turns out that neither display name of the field that is "Employee Address" nor its internal name i.e. "Employee_x0020_Address" work. It is actually the display name minus spaces which works i.e. "EmployeeAddress" as shown:

Here are the rules for working with List fields and List names in REST. 
1. Preserve casing, remove spaces and keep the first letter of each individual word as Capital. For example a field with display name "home aDdress" will be "HomeADdress".
2. If a special character like dot is in field name or List name it is to be treated like space i.e. if field name is "Add.ress" the REST equivalent will be "AddRess"


0 comments

My SharePoint CodePlex Projects

SharePoint 2010 Autocomplete Lookup Field

Export Version History Of SharePoint 2010 List Items to Microsoft Excel.