Skip to content

Commit ad9c0cf

Browse files
Merge pull request SharePoint#5135 from andrewconnell/docfix-restCleanup
SP REST docs cleanup & broken link fixes
2 parents 5e04cc5 + ab41b67 commit ad9c0cf

7 files changed

+807
-943
lines changed

docs/sp-add-ins/determine-sharepoint-rest-service-endpoint-uris.md

Lines changed: 92 additions & 110 deletions
Large diffs are not rendered by default.
Lines changed: 39 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,71 @@
11
---
22
title: Navigate the SharePoint data structure represented in the REST service
3-
description: Start from a REST endpoint for a given SharePoint item, and navigate to and access related items, such as parent sites or the library structure where that item resides.
4-
ms.date: 12/14/2017
3+
description: Start from a REST endpoint for a given SharePoint item, and navigate to and access-related items, such as parent sites or the library structure where that item resides.
4+
ms.date: 1/14/2020
55
ms.prod: sharepoint
66
localization_priority: Priority
77
---
88

9-
# Navigate the SharePoint data structure represented in the REST service
10-
11-
When you're working with the SharePoint REST service, you'll often start out knowing the URL of a specific SharePoint item, but want to access related items, such as the folder or library structure where that item resides. For example, suppose you create an add-in where your user enters the URL of a document in a SharePoint library. Your add-in must then break down that URL to figure out the actual SharePoint site URL. After it's done that, the add-in can then make more requests from the site on the user's behalf, such as to create, update, or delete related items or resources.
9+
When you're working with the SharePoint REST service, you'll often start out knowing the URL of a specific SharePoint item, but want to access related items, such as the folder or library structure where that item resides. For example, suppose you create an add-in where your user enters the URL of a document in a SharePoint library. Your add-in must then break down that URL to figure out the actual SharePoint site URL. After it's done that, the add-in can then make more requests from the site on the user's behalf, such as to create, update, or delete related items or resources.
1210

1311
To do this, your add-in needs to query SharePoint for the following information:
1412

1513
- The server relative URLs of the site and site collection containing the resource.
1614
- A form digest to enable you to perform requests that change the state of the resource, such as **POST**, **PUT**, **MERGE**, and **DELETE**.
1715

18-
### The basic process
16+
## The basic process
1917

2018
1. Use the `/contextinfo` operator with the given URL to access the site and site collection addresses, and the form digest. Use the `/contextinfo` operator in the following format:
21-
22-
`http://server/web/doclib/forms/_api/contextinfo`
23-
19+
20+
```http
21+
POST https://{site_url}/_api/contextinfo
22+
Authorization: "Bearer " + accessToken
23+
Accept: "application/json;odata=verbose"
24+
```
25+
2426
To increase security against cross-site scripting attempts, the `/contextinfo` operator accepts only **POST** requests.
25-
26-
2. Use the [SPContextWebInformation object properties](#bk_props) that the `/contextinfo` operator returns to access additional resources as desired.
27-
28-
29-
### Try it
30-
31-
1. Start with a URL to a given SharePoint item. For example:
32-
33-
`http://site/web/doclib/myDocument.docx`
34-
35-
2. Remove the name of the specific resource from the end of the URL, so that the URL points to a document library, folder, or list. In this case:
36-
37-
`http://site/web/doclib/`
38-
39-
3. Append the REST service pointer and the `/contextinfo` operator to the URL:
40-
41-
`http://site/web/doclib/_api/contextinfo`
42-
43-
4. Read the form digest and **webFullUrl** properties from the response.
44-
45-
5. Append the REST service pointer `_api` to the web URL.
46-
47-
6. Use the resulting URL and the form digest to make requests for other resources you need.
48-
49-
You don't have to pass the form digest if you're making **GET** requests, or making requests using a validated OAuth token.
50-
51-
<a name="bk_sites"> </a>
27+
28+
1. Use the [SPContextWebInformation object properties](#spcontextwebinformation-object-properties) that the `/contextinfo` operator returns to access additional resources as desired.
29+
30+
## Try it
31+
32+
1. Start with a URL to a given SharePoint item. For example: **https://{site_url}/doclib/myDocument.docx**
33+
1. Remove the name of the specific resource from the end of the URL, so that the URL points to a document library, folder, or list. In this case: **https://{site_url}/doclib/**
34+
1. Append the REST service pointer and the `/contextinfo` operator to the URL:
35+
36+
```http
37+
POST https://{site_url}/_api/doclib/contextinfo
38+
Authorization: "Bearer " + accessToken
39+
Accept: "application/json;odata=verbose"
40+
```
41+
42+
1. Read the form digest and **webFullUrl** properties from the response.
43+
1. Append the REST service pointer `_api` to the web URL.
44+
1. Use the resulting URL and the form digest to make requests for other resources you need.
45+
46+
> [!TIP]
47+
> You don't have to pass the form digest if you're making **GET** requests, or making requests using a validated OAuth token.
5248
5349
## Navigate parent and child sites
5450
5551
When you navigate your site structure using the SharePoint server object model, you use the **SPWeb.ParentWeb** and **SPWeb.Webs** properties to access objects that represent parent and child sites.
5652
57-
The corresponding REST resources`web/parentweb` and `web/webs`don't return objects that represent sites. This is because the REST service conforms to OData standards, and returning complete site representations would make such requests inefficient. Instead, they return a [WebInfo object ](#bk_webinfo) that contains the site's scalar properties, but without related entity sets such as like collections or field collections.
53+
The corresponding REST resources, `web/parentweb` and `web/webs`, don't return objects that represent sites. This is because the REST service conforms to OData standards, and returning complete site representations would make such requests inefficient. Instead, they return a [WebInfo object](#webinfo-object) that contains the site's scalar properties, but without related entity sets such as like collections or field collections.
5854
5955
To navigate to a specific parent or child site, construct the appropriate REST URL to that site by using the **Id** or **Title** property. From there, you can access that site's related entity sets.
6056
61-
<a name="bk_folders"> </a>
62-
6357
## Navigate folder structure
6458
6559
The SharePoint REST service does not support traversing the folder hierarchy of a site through the URL construction. Instead, use the REST equivalent of the **Web.GetFolderByServerRelativeUrl** method. For example:
6660
67-
*Navigation not supported through the REST service:*
61+
*Navigation not supported through the REST service:*
62+
63+
`https://{site_url}/_vti_bin/client.svc/web/lists/SharedDocuments/folder1/stuff/things/Recycle`
64+
65+
*Navigation that is supported by the REST service:*
6866
69-
`/_vti_bin/client.svc/web/lists/SharedDocuments/folder1/stuff/things/Recycle`
70-
71-
*Navigation that is supported by the REST service:*
72-
73-
`/_vti_bin/client.svc/web/GetFolderByServerRelativeUrl('SharedDocuments/folder1/stuff/things')/Recycle`
74-
67+
`https://{site_url}/_vti_bin/client.svc/web/GetFolderByServerRelativeUrl('SharedDocuments/folder1/stuff/things')/Recycle`
7568
76-
<a name="bk_props"> </a>
7769
7870
## SPContextWebInformation object properties
7971
@@ -85,8 +77,6 @@ The SharePoint REST service does not support traversing the folder hierarchy of
8577
|**LibraryVersion**|Gets the current version of the REST library.|
8678
|**SupportedSchemaVersions**|Gets the versions of the schema of the REST/CSOM library that are supported.|
8779
88-
<a name="bk_webinfo"> </a>
89-
9080
## WebInfo object
9181
9282
|**WebInfo property**|**Description**|
@@ -100,17 +90,8 @@ The SharePoint REST service does not support traversing the folder hierarchy of
10090
|**WebTemplateId**|Gets the identifier of the site template.|
10191
10292
## See also
103-
<a name="bk_addresources"> </a>
10493
10594
- [Get to know the SharePoint REST service](get-to-know-the-sharepoint-rest-service.md)
106-
- [REST API reference and samples](https://msdn.microsoft.com/library)
10795
- [Use ETag values through the REST service to get document list item versioning](working-with-lists-and-list-items-with-rest.md#using-etag-values-to-determine-document-and-list-item-versioning)
10896
- [OData resources](get-to-know-the-sharepoint-rest-service.md#odata-resources)
10997
- [Develop SharePoint Add-ins](develop-sharepoint-add-ins.md)
110-
111-
112-
113-
114-
115-
116-
Lines changed: 38 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,59 @@
11
---
22
title: Synchronize SharePoint items using the REST service
33
description: Synchronize items between SharePoint and your add-ins or services by using the GetListItemChangesSinceToken resource, part of the SharePoint REST service.
4-
ms.date: 12/14/2017
4+
ms.date: 1/14/2020
55
ms.prod: sharepoint
66
localization_priority: Priority
77
---
88

9-
# Synchronize SharePoint items using the REST service
10-
119
If you want to synchronize items between SharePoint and your add-ins or services, you can use the **GetListItemChangesSinceToken** resource to do so. The **GetListItemChangesSinceToken**, part of the SharePoint REST service, corresponds to the **Lists.GetListItemChangesSinceToken** web service call.
1210

1311
Perform a **POST** request that includes an [SP.ChangeLogItemQuery object properties](#bk_props) object in the request body.
1412

1513
The request returns ADO **rowset** XML, which includes rows corresponding to any list item change matching the specified query. For more information about these properties, including property data structures, CAML element descriptions, and return values, see [Lists.GetListItemChangesSinceToken](https://msdn.microsoft.com/library/office/jj247029.aspx).
1614

17-
### Example
18-
19-
**Example request**
20-
21-
`POST http://server/site/_api/web/Lists/GetByTitle('Announcements')/GetListItemChangesSinceToken`
22-
23-
**Example POST body**
24-
25-
```XML
26-
{ 'd' : {
27-
'query': {
28-
'__metadata': { 'type': 'SP.ChangeLogItemQuery'},
29-
'ViewName': '',
30-
'Query': '
15+
## Example
16+
17+
```http
18+
POST https://{site_url}/_api/web/Lists/GetByTitle('Announcements')/GetListItemChangesSinceToken`
19+
Authorization: "Bearer " + accessToken
20+
Content-Type: "application/json"
21+
Content-Length: {length of request body as integer}
22+
23+
{ "d" : {
24+
"query": {
25+
"__metadata": {
26+
"type": "SP.ChangeLogItemQuery"
27+
},
28+
"ViewName": "",
29+
"Query": "
3130
<Query>
32-
<Where>
31+
<Where>
32+
<Contains>
33+
<FieldRef Name='Title' />
34+
<Value Type='Text'>Te</Value>
35+
</Contains>
36+
</Where>'
37+
</Query>,
38+
"QueryOptions": "
39+
<QueryOptions>
40+
<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>
41+
<DateInUtc>False</DateInUtc>
42+
<IncludePermissions>TRUE</IncludePermissions>
43+
<IncludeAttachmentUrls>FALSE</IncludeAttachmentUrls>
44+
<Folder>Shared Documents/Test1</Folder>
45+
</QueryOptions>',
46+
"ChangeToken":"1;3;eee4c6d5-f88a-42c4-8ce1-685122984870;634397182229400000;3710",
47+
"Contains": "
3348
<Contains>
34-
<FieldRef Name="Title" />
35-
<Value Type='Text'>Te</Value>
36-
</Contains></Where>'</Query>,
37-
'QueryOptions': '<QueryOptions>
38-
<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>
39-
<DateInUtc>False</DateInUtc>
40-
<IncludePermissions>TRUE</IncludePermissions>
41-
<IncludeAttachmentUrls>FALSE</IncludeAttachmentUrls>
42-
<Folder>Shared Documents/Test1</Folder></QueryOptions>',
43-
'ChangeToken':'1;3;eee4c6d5-f88a-42c4-8ce1-685122984870;634397182229400000;3710',
44-
'Contains':'<Contains>
45-
<FieldRef Name="Title"/>
46-
<Value Type="Text">Testing</Value></Contains>' }
47-
}
49+
<FieldRef Name="Title"/>
50+
<Value Type="Text">Testing</Value>
51+
</Contains>"
52+
}
53+
}
4854
}
49-
5055
```
5156

52-
<br/>
53-
54-
<a name="bk_props"> </a>
55-
5657
## SP.ChangeLogItemQuery object properties
5758

5859
|**Property**|**Description**|
@@ -65,18 +66,8 @@ The request returns ADO **rowset** XML, which includes rows corresponding to any
6566
|**Contains**|A [Contains](https://msdn.microsoft.com/library/ms196501.aspx) element that defines custom filtering for the query.|
6667

6768
## See also
68-
<a name="bk_addresources"> </a>
6969

7070
- [Get to know the SharePoint REST service](get-to-know-the-sharepoint-rest-service.md)
7171
- [Use ETag values through the REST service to get document list item versioning](working-with-lists-and-list-items-with-rest.md#using-etag-values-to-determine-document-and-list-item-versioning)
72-
- [REST API reference and samples](https://msdn.microsoft.com/library)
7372
- [OData resources](get-to-know-the-sharepoint-rest-service.md#odata-resources)
7473
- [Develop SharePoint Add-ins](develop-sharepoint-add-ins.md)
75-
76-
77-
78-
79-
80-
81-
82-

0 commit comments

Comments
 (0)