You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sp-add-ins/navigate-the-sharepoint-data-structure-represented-in-the-rest-service.md
+39-50Lines changed: 39 additions & 50 deletions
Original file line number
Diff line number
Diff line change
@@ -1,79 +1,71 @@
1
1
---
2
2
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 accessrelated 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
5
5
ms.prod: sharepoint
6
6
localization_priority: Priority
7
7
---
8
8
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.
12
10
13
11
To do this, your add-in needs to query SharePoint for the following information:
14
12
15
13
- The server relative URLs of the site and site collection containing the resource.
16
14
- A form digest to enable you to perform requests that change the state of the resource, such as **POST**, **PUT**, **MERGE**, and **DELETE**.
17
15
18
-
###The basic process
16
+
## The basic process
19
17
20
18
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
+
24
26
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
-
<aname="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.
52
48
53
49
## Navigate parent and child sites
54
50
55
51
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.
56
52
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.
58
54
59
55
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.
60
56
61
-
<aname="bk_folders"> </a>
62
-
63
57
## Navigate folder structure
64
58
65
59
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:
66
60
67
-
*Navigation not supported through the REST service:*
61
+
*Navigation not supported through the REST service:*
@@ -85,8 +77,6 @@ The SharePoint REST service does not support traversing the folder hierarchy of
85
77
|**LibraryVersion**|Gets the current version of the REST library.|
86
78
|**SupportedSchemaVersions**|Gets the versions of the schema of the REST/CSOM library that are supported.|
87
79
88
-
<aname="bk_webinfo"> </a>
89
-
90
80
## WebInfo object
91
81
92
82
|**WebInfo property**|**Description**|
@@ -100,7 +90,6 @@ The SharePoint REST service does not support traversing the folder hierarchy of
100
90
|**WebTemplateId**|Gets the identifier of the site template.|
101
91
102
92
## See also
103
-
<aname="bk_addresources"> </a>
104
93
105
94
- [Get to know the SharePoint REST service](get-to-know-the-sharepoint-rest-service.md)
106
95
- [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)
Copy file name to clipboardExpand all lines: docs/sp-add-ins/synchronize-sharepoint-items-using-the-rest-service.md
+38-38Lines changed: 38 additions & 38 deletions
Original file line number
Diff line number
Diff line change
@@ -1,58 +1,59 @@
1
1
---
2
2
title: Synchronize SharePoint items using the REST service
3
3
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
5
5
ms.prod: sharepoint
6
6
localization_priority: Priority
7
7
---
8
8
9
-
# Synchronize SharePoint items using the REST service
10
-
11
9
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.
12
10
13
11
Perform a **POST** request that includes an [SP.ChangeLogItemQuery object properties](#bk_props) object in the request body.
14
12
15
13
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).
@@ -65,7 +66,6 @@ The request returns ADO **rowset** XML, which includes rows corresponding to any
65
66
|**Contains**|A [Contains](https://msdn.microsoft.com/library/ms196501.aspx) element that defines custom filtering for the query.|
66
67
67
68
## See also
68
-
<aname="bk_addresources"> </a>
69
69
70
70
-[Get to know the SharePoint REST service](get-to-know-the-sharepoint-rest-service.md)
71
71
-[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)
0 commit comments