Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

Sharepoint 2013 : Overview of The Client-Side Object Model and Rest APIs - REST and OData (part 1) - Getting Started with REST and OData

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
8/17/2014 9:27:03 PM

REpresentational State Transfer (REST) is a prevalent pattern for designing easily consumed data APIs over the Internet. You might hear an API described as RESTful if it is designed to be used over HTTP protocols and is in line with the principles of REST. These principles are as follows:

  • Client-Server: The client is unaware of how the server stores or manages the data and doesn’t need to know in order to use the API.
  • Stateless: The server does not store any context or state about the calling client.
  • Cacheable: The results of the calls to the API define themselves as being cacheable, or not.
  • Layered: The client does not mind whether the call to the API is transmitted via common Internet technology such as load balancers.
  • Uniform Interface: This provides a simple and known way to access data through standard URI addressing and self-describing so that a client can discover how to access data.

Many services offer REST-based APIs to ease access to their systems in a commonly understood manner. SharePoint 2013 builds on this foundation to offer access in a “RESTful” way to allow remote systems to interact with it in a platform agnostic and open way. For developers this means that using other helper libraries and frameworks for working with REST is a viable method, and the time to become proficient in a proprietary API is decreased.

OData or Open Data Protocol is a protocol definition for querying, finding, and updating data over HTTP. It offers defined methods for specifying common query operations and defines the format in which data is returned. SharePoint 2013 uses WCF Data Services v5.0 which implements the OData v3 specification. For more information on OData you can visit: http://www.odata.org.

Combining a RESTful Web API with OData gives a powerful combination of simple and easy-to-use APIs that have a well-defined interface and interaction model. In practical terms, having access to a RESTful OData-based API means the following for SharePoint developers:

  • Standard URIs for addressing data
  • Simple use of GET, POST, PUT/MERGE, and DELETE HTTP methods
  • JSON or XML (ATOM) responses
  • Simple query/filter semantics

The following sections describe each of the preceding points with simple-to-follow examples of how they are addressed in SharePoint 2013’s implementation of its REST/OData Web API endpoints.

Getting Started with REST and OData

You can find SharePoint’s REST/OData APIs in the _API URL space under each SharePoint site. For example:

https://servername/sitename/_api/

_api is the root URI for all REST/OData calls. SharePoint also supports calls to the _vti_bin/client.svc/ URI to maintain backward compatibility with the previously available but more limited REST API in SharePoint 2010.

To query for data, issue a GET request. To update data you use either a PUT or MERGE request passing the data you want to update. But first you must specify which namespace it belongs in, such as Web, Site, or Search. Other groups include:

  • _api/web
  • _api/site
  • _api/search
  • _api/publishing

After you specify a namespace you must address an object, method, indexer, or property on it. Figure 1 depicts the URI address system.

FIGURE 1

image

To retrieve the list of lists on a SharePoint site simply issue a GET request to the following:

https://servername/sitename/_api/web/lists

To retrieve the details about a list simply make a GET request to that list’s URI indicated in the previous response’s id property. For example:

https://servername/sitename/_api/Web/Lists(guid'f57d3ddc-4522-4145-a0fe-72abbd6ea8fc')

This example uses the Lists method with a parameter to specify the ID of the list. You could also use the list’s entity name; for example:

https://servername/sitename/_api/Web/Lists/MoviesList

Additionally, you can address a list by name using the getbytitle function as follows. This addresses the list with its name versus its entity name:

https://servername/sitename/_api/Web/Lists/getbytitle('movies')/items

To access the items within a list add /items to the URI:

https://servername/sitename/_api/Web/Lists/MoviesList/Items

By default you will receive an ATOM feed XML response containing the lists in your site. If you want to receive a JSON payload instead, set the HTTP Accept header to application/json;odata=verbose. This signals that you want JSON instead of the default ATOM payload. JSON is typically lighter weight and better suited to mobile scenarios where speed is important.

Other -----------------
- Sharepoint 2013 : Integrating Apps for Office with SharePoint (part 2) - Apps for Office Integrated with an App for SharePoint
- Sharepoint 2013 : Integrating Apps for Office with SharePoint (part 1) - Standalone Apps for Office
- Sharepoint 2013 : The Office JavaScript Object Model (part 3) - App Security
- Sharepoint 2013 : The Office JavaScript Object Model (part 2) - Functional Capabilities by Office Client,Mailbox-based Apps
- Sharepoint 2013 : The Office JavaScript Object Model (part 1) - Document-based Apps
- SQL Server 2012 : Understanding Latches and Spinlocks (part 3) - Latching Example - With Latching
- SQL Server 2012 : Understanding Latches and Spinlocks (part 2) - Latching Example - Without Latching
- SQL Server 2012 : Understanding Latches and Spinlocks (part 1) - Latching Example
- SQL Server 2012 : Latches and Spinlocks - Symptoms (part 2) - Measuring Latch Contention, Measuring Spinlock Contention , Contention Indicators
- SQL Server 2012 : Latches and Spinlocks - Symptoms (part 1) - Recognizing Symptoms
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server