Get to know the SharePoint 2013 REST service.note¶
Source:
/Volumes/X9 Pro/ObsNotes/YoudaoYunNotes/默认笔记本/Get to know the SharePoint 2013 REST service.note.pdfConverted: 2025-12-10 12:19:23
Get to know the SharePoint 2013 REST service
SharePoint Add-ins
Get the basics of using the SharePoint 2013 REST service to access and update SharePoint data,
using the REST and OData web protocol standards.
Last modified: October 30, 2015
Applies to: SharePoint Add-ins | SharePoint Foundation 2013 | SharePoint Server 2013
SharePoint 2013 introduces a Representational State Transfer (REST) service that is comparable to
the existing SharePoint . 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 SharePoint Add-ins,
solutions, and client applications, using REST web technologies and standard Open Data Protocol
(OData) syntax.
This topic assumes you have a basic familiarity with REST and how to construct REST requests.
SharePoint 2013 adds the ability for you to remotely interact with SharePoint sites by using REST.
Now, you can interact directly with SharePoint objects by using any technology that supports
standard REST capabilities.
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. For
example:
Client object model method:
List.GetByTitle(listname)
REST endpoint:
'listname')
The client.svc 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.
Note
The name "apps for SharePoint" is changing to "SharePoint Add-ins". During the transition, the
documentation and the UI of some SharePoint products and Visual Studio tools might still use the
term "apps for SharePoint". For details, see .New name for apps for Office and SharePoint
client object models
Prerequisites
How the SharePoint 2013 REST service works
http://server/site/_api/lists/getbytitle(
SharePoint REST service architecture
Because of the functionality and ease of use that client object models provide, they remain the
primary development option for communicating with SharePoint sites by using .NET Framework
managed code, Silverlight, or JavaScript.
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. The client.svc web service handles the HTTP request and serves the appropriate response in
either Atom or JavaScript Object Notation (JSON) format. The client application must then parse that
response.
The endpoints in the SharePoint 2013 REST service correspond to the types and members in the
SharePoint client object models. By using HTTP requests, you can use these REST endpoints to
perform typical CRUD operations against SharePoint entities, such as lists and sites.
In general:
Use HTTP commands with the SharePoint 2013 REST service
If you want to do this to an
endpoint Use this HTTP request Keep in mind
Read a resource GET
Create or update a resourcePOST
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 resourcePUT
Use PUT and MERGE operatio
ns to update existing
SharePoint objects.
Any service endpoint that
represents an object
property set operation supports
both PUT requests
and MERGE requests.
MERGE requests, setting
properties is optional; any
properties that you do not
explicitly set retain their current
property.
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.
For
For
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.
Whenever possible, the URI for these REST endpoints closely mimics the API signature of the
resource in the SharePoint client object model. The main entry points for the REST service represent
the site collection and site of the specified context.
To access a specific site collection, use the following construction:
To access a specific site, use the following construction:
In each case, server represents the name of the server, and site represents the name of, or path to,
the specific site.
From this starting point, you can then construct more specific REST URIs by ''walking" the object
model, using the names of the APIs from the client object model separated by a forward slash (/).
This syntax doesn’t apply to the SocialFeedManager or SocialFollowingManager REST APIs. See
and
for more information.
See for more guidelines for determining
SharePoint REST endpoint URIs from the signature of the corresponding client object model APIs.
The following table contains typical REST endpoint URL examples to get you started working with
SharePoint data. Prepend to the URL fragments shown in the table to
construct a fully qualified REST URL. Where necessary for POSTcommands, the table contains
sample data you must pass in the HTTP request body to create the specified SharePoint item. Items
in italics represent variables that you must replace with your values.
Construct REST URLs to access SharePoint resources
http://server/site/_api/site
http://server/site/_api/web
So
cial feed REST API reference for SharePoint 2013Following people and content REST API refer
ence for SharePoint 2013
Determine SharePoint REST service endpoint URIs
SharePoint REST endpoint examples
http://server/site/_api/
Description URL endpoint HTTP method Body content
Retrieves the title of a
list web/title GET Not applicable
Retrieves all lists on a
site lists GET Not applicable
Retrieves a single 'list's
metadata
lists/getbytitle(
'listname') GET Not applicable
Retrieves items within
a list
lists/getbytitle(
'listname')/itemsGET Not applicable
Retrieves a specific
property of a
document. (In this
case, the document
title.)
lists/getbytitle(
'listname')?
select=Title GET Not applicable
Creates a list lists POST
{1
'_metadata':
{'type':SP.List}
,
2
'AllowContentTyp
es': true,
3
'BaseTemplate':
104,
4
'ContentTypesEna
bled': true,
5
'Description':
'My list
description',
6
'Title':
'RestTest'
7
}8
9
Adds an item to a listlists/getbytitle(
'listname')/itemsPOST
{1
'_metadata':
{'type':SP.listn
ameListItem},
2
'Title':
'MyItem'
3
}4
5