How to: Create a REST Service Proxy


The Microsoft® SharePoint® Foundation REST interface provides a simple and robust mechanism for accessing SharePoint list data from external applications. Although REST services can be accessed directly by using HTTP verbs, and manipulated by using either Atom or JavaScript Object Notation (JSON), you can also generate a Windows Communication Foundation (WCF) Data Services client proxy for the REST service. This allows developers to interact with the REST service by using strongly typed objects and a consistent development model.

This how-to topic assumes that you have used the Microsoft Visual Studio® 2010 development system to create a solution that contains a Microsoft Silverlight® application project, and that you have installed and configured ADO.NET Data Services in your development environment, as described in the SharePoint 2010 installation prerequisites.


This procedure describes how to use Visual Studio 2010 to create a service proxy for the SharePoint REST interface. You can use this service proxy to interact with the REST service from client-side code. This procedure assumes that you have already created a Visual Studio 2010 project.

To generate a service proxy

  1. In Solution Explorer, right-click the project node, and then click Add Service Reference.
  2. In the Add Service Reference dialog box, in the Address text box, type the URL of the REST service, and then click Go.
    The REST interface is exposed on every SharePoint site. The URL of the REST service is <site URL>/_vti_bin/ListData.svc.


  3. In the Services list box, select the REST service. In the Namespace text box, type the friendly name for the service, and then click OK.
    The REST service will always be named <sitename>DataContext, where <sitename> is the name of the SharePoint site.


    When you click OK, Visual Studio creates the service proxy classes. You can now use the service proxy to interact with the REST interface from your code.

  4. In the code-behind for your Silverlight control, instantiate the data context class, using the fully qualified URL of the REST service.
    You should declare and instantiate the data context at the class level so that it is available to all the methods on your control.

    PartsDataContext context = new PartsDataContext(new 

You can now use the data context to create and submit queries to the REST interface. For more information about using the service proxy with the REST interface, see the Client Reference Implementation.