【问题标题】:How to add share points CAML query in rest service如何在休息服务中添加共享点 CAML 查询
【发布时间】:2016-05-26 16:36:05
【问题描述】:

这是我的 SharePoint CAML 查询条件

<View>
     <Query>
     <Where>
     <Geq>
       <FieldRef Name='EventDate' />
         <Value Type='DateTime' IncludeTimeValue='TRUE'>2016-04-28T06:04:28.183Z</Value>
     </Geq>
    </Where>
    </Query>
</View> 

我尝试使用 REST url 复制它,但我收到了消息

“'DateTime' 类型的字段 'EventDate' 不能在查询过滤器表达式中使用”。

谁能指导我更正我的网址

http://mySite//_api/lists/getbytitle('test')/items?$filter=EventDate gt datetime'2016-04-04T00:00:00'

【问题讨论】:

    标签: sharepoint sharepoint-2013


    【解决方案1】:

    您必须在 ajax 调用的数据部分编写 caml 查询并发布它。

    $.ajax({
        url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('listname')/getitems",
        type: "POST",
        headers: {
            "accept": "application/json;odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val(),
            "content-Type": "application/json;odata=verbose"
        },
        data: JSON.stringify({ 
        query : {
          __metadata: {
            type: "SP.CamlQuery" 
          },
          ViewXml: 'Your CAML Query'
        }
      }),
        success: function (d) {
            console.log(d);
        },
        error: function (error) {
            console.log(JSON.stringify(error));
        }
    });
    

    更新:

    日期比较语法有点不同。还 ”?”物品丢失后。这是更新后的 URL ==> http://mysite/_api/lists/getbytitle('test')/items?$filter=EventDate gt datetime'2016-04-04T00:00:00'

    【讨论】:

    • 您好 Vijay ata,感谢您的回复。我需要根据我的骆驼查询形成一个 Rest URl。
    • 日期比较语法有点不同。还 ”?”物品丢失后。这是更新后的 URL ==> http://mysite/_api/lists/getbytitle('test')/items?$filter=EventDate gt datetime'2016-04-04T00:00:00'
    • 您好,我尝试使用更新的 URL,但仍然收到相同的消息。
    猜你喜欢
    • 1970-01-01
    • 2013-07-05
    • 2016-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多