四度空间

专注.NET SharePoint

SharePoint REST API - 同步SharePoint列表项

博客地址:http://blog.csdn.net/FoxDave

本篇只讲REST服务中的GetListItemChangesSinceToken这个东西。何谓同步呢,你也可以理解为增量变化,即给定一个时间,我需要获取从那个时间到现在所有发生变化的列表项。

使用GetListItemChangesSinceToken同步SharePoint列表项

如果你想要在SharePoint和你的Add-in或服务之间同步列表项,可以使用GetListItemChangesSinceToken来达到目的,它跟SharePoint Web服务请求中的List.GetListItemChangesSinceToken是对应的。

在POST请求的body中加入SP.ChangeLogItemQuery对象的属性。该请求会返回ADO行集合的XML,包含了符合查询条件的列表项的更改记录。

示例请求如下:

请求的URL

POST http://server/site/_api/web/Lists/GetByTitle('Announcements')/GetListItemChangesSinceToken

请求的Body

{ 'd' : { 
  'query': { 
    '__metadata': { 'type': 'SP.ChangeLogItemQuery'}, 
    'ViewName': '', 
    'Query': '<Where>
      <Contains>
         <FieldRef Name="Title" />
         <Value Type='Text'>Te</Value>
      </Contains></Where>',
    '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对象属性

PropertyDescription
ListNameA 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.
ViewNameA string that contains the GUID for the view, which determines the view to use for the default view attributes represented by the  queryviewFields, and  rowLimit parameters. If this argument is not supplied, the default view is assumed. If it is supplied, the value of the queryviewFields, 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.
QueryQuery element containing the query that determines which records are returned and in what order.
QueryOptionsAn XML fragment in the following form that contains separate nodes for the various properties of the  SPQuery object.
ChangeTokenA 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.
ContainsContains element that defines custom filtering for the query.
本篇就介绍到这里。
阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/FoxDave/article/details/78132712
个人分类: SharePoint REST
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭