One of the biggest change in SharePoint 2013 the search service is extended with REST capabilities.  This means, it now supports direct access from REST-based clients – includes client-side applications, non .NET applications apart from .NET-applications.  It also has a new shorthand notation for accessing the REST API where CSOM URLs can be accessed through the _api folder. This means that now you don’t access them with _vti_bin in the URL and you can directly use _api as shown below

http://sharepoint/_vti_bin/client.svc/web  but  http://sharepoint/_api/web

SharePoint 2013 REST API follows the Open Data Protocol specification but also extends it in some ways to support more complex SharePoint specific operations. The SharePoint 2013 REST service responses are formatted by using the Atom protocol by default.  But it is also possible to use with HTTP Protocol by using HTTP Accept headers.  With HTTP, you can specify that the response is required in JSON format and this can be used in Javascript/jQuery code.

Since a number of REST calls are simple GET operations it is possible to learn the syntax by creating the URL in a browser and looking at the ATOM response being returned. Next are some of examples to get you started:

  • https://[yoursharepointsite]/_api/web/
    – access a specific site and retrieves different properties
  • https://[yoursharepointsite]/_api/web/?$select=Title,Id
    – only retrieves the Title and ID for a specific site
  • https://[yoursharepointsite]/_api/lists
    – retrieves all lists on a specific site
  • https://[yoursharepointsite]/_api/lists/getByTitle(‘Consultants’)
    – retrieves a single list based on the title used
  • https://[yoursharepointsite]/_api/lists/getByTitle(‘Consultants’)/Items
    – retrieves all items in the list with all the fields returned
  • https://[yoursharepointsite]/_api/lists/getByTitle(‘Consultants’)/Items/?$select=Title,LastName
    – retrieves for all items in the list only the Title and LastName field
  • https://[yoursharepointsite]/_api/web/lists/getByTitle(‘Consultants’)/Items/?$select=Title,FirstName&$filter=startswith(Title,’C’)
    – retrieves  items in the list where the Title starts with a C and retrieves the Title and LastName field

In the next post, will explore the extensions in the REST API for SharePoint Server 2013.

More information on REST Services, you can refer to:

Krunal Patel

I am SharePoint Senior Developer and currently working on SharePoint-15 Beta. I started programming on 8085 assembly language and then moved to MS technology. I have also worked as android developer as my hobby.

More Posts - Website

Follow Me:
TwitterLinkedIn

Tagged with →  
Share →
%d bloggers like this: