Professional Documents
Culture Documents
To access SharePoint resources using REST, construct a RESTful HTTP request by using the OData standard,
which corresponds to the desired client object model API. For example:
HTTP :
GET https://{site_url}/_api/lists/getbytitle('{list_name}')/items
Authorization: "Bearer " + accessToken
Accept: "application/json;odata=verbose"
To use the REST capabilities that are built into SharePoint, you construct a RESTful HTTP request by 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 JSON format. The client
application must then parse that response.
The endpoints in the SharePoint 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 do typical CRUD operations
against SharePoint entities, such as lists and sites.
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.
HTTP :
https://{site_url}/_api/site
HTTP :
https://{site_url}/_api/web
In each case, server represents the name of the server, and site represents the name of, or path to, the specific site.
…/_api/web/lists(guid'<list
Form SPForm SP.Form object id>')/forms('<form id>')
Navigation SPNavigation SP.Navigation object …/_api/web/navigation
RecycleBinItem
SP.RecycleBinItem object …/_api/web/RecycleBin(recyclebinitemid)
SPRecycleBinItem
RecycleBinItemCollection
SP.RecycleBinItemCollection object …/_api/web/RecycleBin
SPRecycleBinItemCollection
RegionalSettings SPRegionalSettings SP.RegionalSettings object …/_api/web/RegionalSettings
POST https://{site_url}/_api/web/lists
Authorization: "Bearer " + accessToken
Accept: "application/json;odata=verbose"
Content-Type: "application/json"
Content-Length: {length of request body as integer}
X-RequestDigest: "{form_digest_value}"
{
"__metadata": {
"type": "SP.List"
},
"AllowContentTypes": true,
"BaseTemplate": 100,
"ContentTypesEnabled": true,
"Description": "My list description",
"Title": "Test"
}
The following example shows how to update a list by using the MERGE method.
HTTP
POST https://{site_url}/_api/web/lists(guid'{list_guid}')
Authorization: "Bearer " + accessToken
Accept: "application/json;odata=verbose"
Content-Type: "application/json"
Content-Length: {length of request body as integer}
If-Match: "{etag or *}"
X-HTTP-Method: "MERGE"
X-RequestDigest: "{form_digest_value}"
{
"__metadata": {
"type": "SP.List"
},
"Title": "New title"
}
The following example shows how to create a custom field for a list
HTTP
POST https://{site_url}/_api/web/lists(guid'{list_guid}')/Fields
Authorization: "Bearer " + accessToken
Accept: "application/json;odata=verbose"
Content-Type: "application/json"
Content-Length: {length of request body as integer}
X-RequestDigest: "{form_digest_value}"
{
"__metadata": {
"type": "SP.Field"
},
"Title": "field title",
"FieldTypeKind": FieldType value,
"Required": "true/false",
"EnforceUniqueValues": "true/false",
"StaticName": "field name"
}
HTTP
POST https://{site_url}/_api/web/lists(guid'{list_guid}')
Authorization: "Bearer " + accessToken
Accept: "application/json;odata=verbose"
If-Match: "{etag or *}"
X-HTTP-Method: "DELETE"
X-RequestDigest: "{form_digest_value}"
When referring to a lookup column inside a list using REST API, use the display name of the lookup column
instead of the internal name.
HTTP
GET https://{site_url}/_api/web/lists/getbytitle('ListName')/Items?&$filter=LookupColumnId
eq 1
Authorization: "Bearer " + accessToken
Accept: "application/json;odata=verbose"
HTTP
GET https://{site_url}/_api/web/lists/GetByTitle('Test')/items
Authorization: "Bearer " + accessToken
Accept: "application/json;odata=verbose"
HTTP
GET https://{site_url}/_api/web/lists/GetByTitle('Test')/items({item_id})
Authorization: "Bearer " + accessToken
Accept: "application/json;odata=verbose"
The following XML shows an example of the list item properties that are returned when you request the XML
content type.
XML
<content type="application/xml">
<m:properties>
<d:FileSystemObjectType m:type="Edm.Int32">0</d:FileSystemObjectType>
<d:Id m:type="Edm.Int32">1</d:Id>
<d:ID m:type="Edm.Int32">1</d:ID>
<d:ContentTypeId>0x010049564F321A0F0543BA8C6303316C8C0F</d:ContentTypeId>
<d:Title>an item</d:Title>
<d:Modified m:type="Edm.DateTime">2012-07-24T22:47:26Z</d:Modified>
<d:Created m:type="Edm.DateTime">2012-07-24T22:47:26Z</d:Created>
<d:AuthorId m:type="Edm.Int32">11</d:AuthorId>
<d:EditorId m:type="Edm.Int32">11</d:EditorId>
<d:OData__UIVersionString>1.0</d:OData__UIVersionString>
<d:Attachments m:type="Edm.Boolean">false</d:Attachments>
<d:GUID m:type="Edm.Guid">eb6850c5-9a30-4636-b282-234eda8b1057</d:GUID>
</m:properties>
</content>