Synchronize SharePoint items using the REST service
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.
Perform a POST request that includes an SP.ChangeLogItemQuery object properties object in the request body.
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.
Example
POST https://{site_url}/_api/web/Lists/GetByTitle('Announcements')/GetListItemChangesSinceToken`
Authorization: "Bearer " + accessToken
Content-Type: "application/json"
Content-Length: {length of request body as integer}
{
"d" : {
"query": {
"__metadata": {
"type": "SP.ChangeLogItemQuery"
},
"ViewName": "",
"Query": "
<Query>
<Where>
<Contains>
<FieldRef Name='Title' />
<Value Type='Text'>Te</Value>
</Contains>
</Where>'
</Query>,
"QueryOptions": "
<QueryOptions>
<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>
<DateInUtc>False</DateInUtc>
<IncludePermissions>TRUE</IncludePermissions>
<IncludeAttachmentUrls>FALSE</IncludeAttachmentUrls>
<Folder>Shared Documents/Test1</Folder>
</QueryOptions>',
"ChangeToken":"1;3;eee4c6d5-f88a-42c4-8ce1-685122984870;634397182229400000;3710",
"Contains": "
<Contains>
<FieldRef Name="Title"/>
<Value Type="Text">Testing</Value>
</Contains>"
}
}
}
SP.ChangeLogItemQuery object properties
Property | Description |
---|---|
ListName | A string that contains either the title or the GUID for the list. When querying the UserInfo table, the string contains UserInfo. Using the GUID results in better performance. |
ViewName | A string that contains the GUID for the view, which determines the view to use for the default view attributes represented by the query, viewFields, and rowLimit parameters. If this argument is not supplied, the default view is assumed. If it is supplied, the value of the query, viewFields, or rowLimit parameter overrides the equivalent setting within the view. For example, if the view specified by the viewFields parameter has a row limit of 100 rows, but the rowLimit parameter contains a value of 1000, then 1,000 rows are returned in the response. |
Query | A Query element containing the query that determines which records are returned and in what order. |
QueryOptions | An XML fragment in the following form that contains separate nodes for the various properties of the SPQuery object. |
ChangeToken | A string that contains the change token for the request. For a description of the format that is used in this string, see Overview of the Change Log. If null is passed, all items in the list are returned. |
Contains | A Contains element that defines custom filtering for the query. |