restful中的token

本篇只讲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

[html]  view plain  copy
  1. { 'd' : {   
  2.   'query': {   
  3.     '__metadata': { 'type': 'SP.ChangeLogItemQuery'},   
  4.     'ViewName': '',   
  5.     'Query': '<Where>  
  6.       <Contains>  
  7.          <FieldRef Name="Title" />  
  8.          <Value Type='Text'>Te</Value>  
  9.       </Contains></Where>',  
  10.     'QueryOptions': '<QueryOptions>  
  11.       <IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>  
  12.       <DateInUtc>False</DateInUtc>  
  13.       <IncludePermissions>TRUE</IncludePermissions>  
  14.       <IncludeAttachmentUrls>FALSE</IncludeAttachmentUrls>  
  15.       <Folder>Shared Documents/Test1</Folder></QueryOptions>',   
  16.     'ChangeToken':'1;3;eee4c6d5-f88a-42c4-8ce1-685122984870;634397182229400000;3710',   
  17.     'Contains':'<Contains>  
  18.       <FieldRef Name="Title"/>  
  19.       <Value Type="Text">Testing</Value></Contains>' }   
  20.   }   
  21. }  

SP.ChangeLogItemQuery对象属性

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 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 Contains element that defines custom filtering for the query.
本篇就介绍到这里。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值