ARTICLE

REST API in SharePoint 2010 for listdata.svc: Part 1

Posted by Vijai Anand Articles | SharePoint 2010 June 16, 2011
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.
Reader Level:

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.

RestApiShare1.gif

Try hitting the URL and you will be getting the XML file of the entire list available in the site.

RestApiShare2.gif

To get the specific item from the tasks list enter the following URL

http://<servername>/_vti_bin/listdata.svc/Tasks(2)/Title

RestApiShare3.gif

To get the specific item from the tasks list enter the following URL

http://<servername>/_vti_bin/listdata.svc/Tasks(2)/Title


RestApiShare4.gif

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'

RestApiShare5.gif

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

RestApiShare6.gif

Login to add your contents and source code to this article
post comment
     

Hi, Iam using rest api in sharepoint 2010 foundation. Iam not able to get 'user' kind of fields using this. like 'owner' , 'requestor' 'createdBy' etc. i have tried all the possible combinations, example: http://server/sites/demo/_vti_bin/listdata.svc/TSRTicket its not working in case of user kind of field. Please help

Posted by Sachin Goyal Feb 26, 2013
COMMENT USING
PREMIUM SPONSORS
Over-C is a holistic consortium of communications and technology specialists. We build, deploy and market both business as well as consumer products and solutions.
Join a Chapter
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.