Archive

Posts Tagged ‘REST’

SharePoint 2010 Data Services

April 30th, 2011 Abed Khooli No comments

You can still access and use the old ASP.NET (.asmx) web  services in SharePoint 2010. These are used, mostly, to access SharePoint data remotely as in remote admin, for bulk operations, and – of course – for backward compatibility. Their use is not encouraged as of the 2010 version especially as a replacement of the server side object model (in code) or when a better option exists or can be built.
The new data service is REST compatible and based on the Open Data protocol. It uses the normal HTTP requests and is called the WCF (Windows Communication Foundation) service.
You can see the available lists at a certain site by browsing to http://site-address/_vti_bin/listdata.svc where an XML file is displayed showing available site lists. It should be noticed, however, that spaces are ignored in list and library titles, so “my great list” becomes mygreatlist.
You can access the data of a certain list by appending the list title (no spaces) to the above URL, so http://site-address/_vti_bin/listdata.svc/TeamTasks will retrieve all items of the Team Tasks list in XML format (TeamTasks is the List Title here). You can get a specific item by specifying its ID – ex.  http://site-address/_vti_bin/listdata.svc/TeamTasks(3) for the item with ID = 3 or http://teams/test/_vti_bin/listdata.svc/TeamTasks(3)/Title to get, only, the title of that item. You can even make queries with filters like http://site-address/_vti_bin/listdata.svc/TeamTasks?$filter=StatusValue eq ‘Completed’ which filters completed tasks in a task list (notice that StatusValue is used here as this is the actual title of the Status column in task lists).

You can do other filtering and sorting and also other operations (in addition to retrieve aka GET). These are POST (create), PUT (Update all fields), MERGE (Update specific fields) and DELETE (Delete). There is more at Using REST Interface.
If you receive an error like “could not load type ..” when you try to access the available lists, you will need this Data Service Update (Win 7 and 2008 R2).