SharePoint 2013 REST service Basics : SharePoint 2013 introduces a Representational State Transfer (REST) service that is comparable to the existing SharePoint client object models. Now, developers can interact remotely with SharePoint data by using any technology that supports REST web requests.
 This means that developers can perform Create, Read, Update, and Delete (CRUD) operations from their apps for SharePoint, solutions, and client applications, using REST web technologies and standard Open Data Protocol (OData) syntax. how it works : To access SharePoint resources using REST,
construct a RESTful HTTP request, using the Open Data Protocol (OData) standard, which corresponds to the desired client object model API.
Client object model method:
List.GetByTitle(listname)
REST endpoint:
http://server/site/_api/lists/getbytitle('listname')
 The (client.svc in 2010) renamed as (_api in 2013 sharepoint ) web service in SharePoint handles the HTTP request, and serves the appropriate response in either Atom or JSON (JavaScript Object Notation) format. Your client application must then parse that response.

 The figure below shows a high-level view of the SharePoint REST architecture. SharePoint REST service architecture
Use HTTP commands with the SharePoint 2013 REST service To use the REST capabilities that are built into SharePoint 2013, you construct a RESTful HTTP request, using the OData standard, which corresponds to the client object model API you want to use.

By using HTTP requests, you can use these REST endpoints to perform typical CRUD operations against SharePoint entities, such as lists and sites.

If you want to do this to an endpoint
Use this HTTP request Keep in mind Read a resource GET Create or update a resource POST Use POST to create entities such as lists and sites.
 The SharePoint 2013 REST service supports sending POST commands that include object definitions to endpoints that represent collections. For POST operations, any properties that are not required are set to their default values.
 If you attempt to set a read-only property as part of a POST operation, the service returns an exception. Update or insert a resource PUT Use PUT and MERGE operations to update existing SharePoint objects. Any service endpoint that represents an object property set operation supports both PUT requests and MERGE requests.

For MERGE requests, setting properties is optional; any properties that you do not explicitly set retain their current property. For PUT requests, if you do not specify all required properties in object updates, the REST service returns an exception.

In addition, any optional properties you do not explicitly set are set to their default properties. Delete a resource DELETE Use the HTTP DELETE command against the specific endpoint URL to delete the SharePoint object represented by that endpoint. In the case of recyclable objects, such as lists, files, and list items, this results in a Recycle operation.

If you want to do this to an endpoint
Use this HTTP request
Keep in mind
Read a resource
GET
Create or update a resource
POST
Use POST to create entities such as lists and sites. The SharePoint 2013 REST service supports sending POST commands that include object definitions to endpoints that represent collections.
For POST operations, any properties that are not required are set to their default values. If you attempt to set a read-only property as part of a POST operation, the service returns an exception.
Update or insert a resource
PUT
Use PUT and MERGE operations to update existing SharePoint objects.
Any service endpoint that represents an object property set operation supports both PUT requests and MERGE requests.
  • For MERGE requests, setting properties is optional; any properties that you do not explicitly set retain their current property.
  • For PUT requests, if you do not specify all required properties in object updates, the REST service returns an exception. In addition, any optional properties you do not explicitly set are set to their default properties.
Delete a resource
DELETE
Use the HTTP DELETE command against the specific endpoint URL to delete the SharePoint object represented by that endpoint.
In the case of recyclable objects, such as lists, files, and list items, this results in a Recycle operation.

 ref:http://msdn.microsoft.com/en-us/library/office/fp142380(v=office.15).aspx

Comments