rest – OData substringof或startswith返回所有项目

我正在尝试从Rest Call中过滤我的结果.
$.ajax({
    type: "GET",headers: {
        "Accept": "application/json;odata=verbose"
    },dataType: "JSON",url: _spPageContextInfo.webServerRelativeUrl + "/_api/lists/getByTitle('Contacts')/items?$select=Title,Id&$startswith('Title','" + request.term + "') eq true",success: function (data) {
    },error: function (ex) {
    }
});

在我的联系人列表中,我正在尝试检索以字符串开头或在其中包含字符串的项目的标题和ID,这里例如它是某人的名字.

我也尝试过substringof:

"/_api/lists/getByTitle('Contacts')/items?$select=Title,Id&$substringof(" + request.term + ",'Title') eq true"

这也提供了相同的结果.

它为我提供了列表中的所有列表项,并且未应用过滤.
在看完Programming using the SharePoint 2013 REST service之后,我为其他人建立了Url
就像在那里给出的Schema一样,我认为Url看起来不错,但似乎不是这样:)

编辑:

在OData Uri约定中应用$filter会给我以下错误

{"error":{"code":"-1,Microsoft.SharePoint.SPException","message":{"lang":"en-US","value":"The query is not valid."}}}

尝试使用以下查询字符串:

_api/lists/getByTitle('Contacts')/items?$select=Title,Id&$filter=substringof(m,'Title') eq true

_api/lists/getByTitle('Contacts')/items?$select=Title,Id&$filter=substringof('m',Title) eq true

解决方法

当我删除“eq true”时,我设法使用substringof过滤器返回正确的结果.

使用您的一个查询字符串,它应该像这样工作:

_api/lists/getByTitle('Contacts')/items?$select=Title,Title)

我还没有检查过任何其他函数,但至少在startswith函数中也是这样.

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...