Introduction:
In SharePoint 2010, we can get the list data using SharePoint object model,
client object model or LINQ to SharePoint, we can also get the list data from
listdata.svc. We can get the list data from listdata.svc using REST
(Representational State Transfer). We can construct URLs in various manners to
get specific records, do joins, or perform simple queries. ListData.svc web
service will be available in _vti_bin folder of the SharePoint site.
Get the data using REST API:
Typical URL to get the data from the SharePoint site using the REST API
http://<servername>/_vti_bin/listdata.svc.
I have a team site "VJTesting" which contains the "Tasks" list.
Tasks list has the following items as shown in the following.
Try hitting the URL and you will be getting the XML file of the entire list
available in the site.
To get the specific item from the tasks list enter the following URL
http://<servername>/_vti_bin/listdata.svc/Tasks(2)/Title
To get the specific item from the tasks list enter the following URL
http://<servername>/_vti_bin/listdata.svc/Tasks(2)/Title
We can also use the filter the data from the list using $filter.
Filter - Restrict the entities returned from a query by applying the
expression specified in this operator to the entity set identified by the last
segment of the URI path.
For example
http://<servername>/_vti_bin/listdata.svc/Tasks?$filter=Title eq 'Task3'
Top - This is used to restrict the maximum number of entities to be
returned.
For example
http://<servername>/_vti_bin/listdata.svc/Tasks?$top=1