SharePoint 2010 REST Interface

SharePoint 2010 REST Interface
4 votes, 5.00 avg. rating (97% score)


In this post we will see how we can work with SharePoint REST interface;also known as WCF Data Services(formerly known as ADO.NET Data Services).
This post provides how to query list data in Microsoft SharePoint Foundation by using Representational State Transfer (REST) Web service.
SharePoint 2010 implements WCF Data Services for all lists and libraries. This means you can perform operations on list items using simple URIs.


WCF Data Services has several advantages over the client object models.
1.WCF Data Services provides a strongly typed ORM layer that you can use in code to access SharePoint lists and items.
In the client object model, all lists and items are returned as more generic types like List and ListItem.

2.WCF Data Services supports LINQ queries against SharePoint lists, whereas the client object model relies on CAML queries.

3.WCF Data Services uses GET, PUT, POST, and DELETE operations in HTTP so any client that supports HTTP can access SharePoint lists.


WCF Data Services can be used it immediately by simply opening a browser and issuing URI commands.
SharePoint 2010 supports the URI commands through a WCF service named ListData.svc. ListData.svc is located in the ISAPI directory, which is accessible through URIs containing _vti_bin.
Ex: Following URI returns information about all the lists available in “mysite” as xml format.


If you are unable to get xml data or any error comes; ensure that latest ADO.NET Data Services are properly installed or not.

Accessing ListData

REST Interfaces supports full CRUD operations on the SharePoint lists. After getting the items from the LINQ query, they can be updated and saved. Changes are sent back to the list when we call the SaveChanges method of the context object.
Creating new items and deleting items are performed using the AddTo and DeleteObject methods.

Following is the sample c# code how we can

get complete lists data

Add Service references to ListData.svc. ListDataServiceRef is the proxy class name given

ListDataServiceRef.ClientObjectModelDataContext ctxObject =   new 
  ListDataServiceRef.ClientObjectModelDataContext(new Uri("http://mysitecollection/mysite/_vti_bin/ListData.svc"));
ctxObject.Credentials = CredentialCache.DefaultCredentials;
var q = from E in  ctxObject.EmpInfo 
        orderby E.FirstName
        select E;

Following are other ways of service usage

Getting only ‘EmpInfo’ list data


Getting ‘EmpInfo’ list data with Id equal to “3”


Getting ‘EmpInfo’ list data results with ordery by ‘FirstName’ field


Get only specific results from ‘EmpInfo’ list

http://mysitecollection/mysite/_vti_bin/ListData.svc/EmpInfo?$filter=FirstName eq ‘Adi’


Client-side technologies like REST interface and client object model are more powerful in SharePoint 2010 than in any previous version of the software.
We should give strong consideration to including them in your SharePoint solutions especially while displaying data from list where we need to implement paging and sorting.
Hope you enjoyed one of the good features of sharepoint 2010, happy coding :)

April 1, 2012 В· Adi В· No Comments
Tags: , , , , ,  В· Posted in: Client Object Model, REST Interface, Sharepoint 2010

Leave a Reply

What is 12 + 5 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)