2017-09-08 35 views
0

我想从SharePoint列表中查询一些信息。现在,我正在尝试使用odata来获取它。我的问题是,由于某种原因,$ filter不能处理该列表中的所有密钥:S。这里有一个例子:

该工程确定

  1. ... CCM/_api /列表/ GetByTitle( '巡回%20Deliveries')/项目$过滤= 标题 EQ“AUG? “

但这一个不工作(HTTP 400坏请求)

  • .. .ccm/_api /列表/ GetByTitle( '巡回%20Deliveries')/项目?$滤芯的Delivery_x0020_Date EQ空
  • 然而,字段名称是确定的,因为我可以使用select和使用的OrderBy相同的字段名称。下面是在IE XML输出2 '标题' 命名的AUG:

    ... CCM/_api /列表/ GetByTitle( '巡回%20Deliveries')/项目$过滤器=标题 EQ “AUG? “& $选择=标题,Delivery_x0020_Date,Status_x0020__x002d__x0020_Calcu

    <?xml version="1.0" encoding="utf-8" ?> - 
     
    <feed xml:base="/ccm/_api/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" 
     
        xmlns:gml="http://www.opengis.net/gml"> 
     
        <id>5a2630a8-c00a-4baa-bd43-3912d9264df8</id> 
     
        <title /> 
     
        <updated>2017-09-08T10:58:12Z</updated> 
     
        <entry m:etag="" 33 ""> 
     
        <id>Web/Lists(guid'5ad8ca39-191a-4586-bdef-7bc4830eced9')/Items(332)</id> 
     
        <category term="SP.Data.Circuit_x0020_DeliveriesListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> 
     
        <link rel="edit" href="Web/Lists(guid'5ad8ca39-191a-4586-bdef-7bc4830eced9')/Items(332)" /> 
     
        <title /> 
     
        <updated>2017-09-08T10:58:12Z</updated> 
     
        <author> 
     
         <name /> 
     
        </author> 
     
        <content type="application/xml"> 
     
         <m:properties> 
     
         <d:Title>AUG</d:Title> 
     
         <d:Delivery_x0020_Date m:type="Edm.DateTime">2017-03-06T06:00:00Z</d:Delivery_x0020_Date> 
     
         <d:Status_x0020__x002d__x0020_Calcu>Circuit Ready for Production Use on 03/06/2017</d:Status_x0020__x002d__x0020_Calcu> 
     
         </m:properties> 
     
        </content> 
     
        </entry> 
     
        <entry m:etag="" 58 ""> 
     
        <id>Web/Lists(guid'5ad8ca39-191a-4586-bdef-7bc4830eced9')/Items(333)</id> 
     
        <category term="SP.Data.Circuit_x0020_DeliveriesListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> 
     
        <link rel="edit" href="Web/Lists(guid'5ad8ca39-191a-4586-bdef-7bc4830eced9')/Items(333)" /> 
     
        <title /> 
     
        <updated>2017-09-08T10:58:12Z</updated> 
     
        <author> 
     
         <name /> 
     
        </author> 
     
        <content type="application/xml"> 
     
         <m:properties> 
     
         <d:Title>AUG</d:Title> 
     
         <d:Delivery_x0020_Date m:null="true" /> 
     
         <d:Status_x0020__x002d__x0020_Calcu>Site Survey completed on 09/09/2016</d:Status_x0020__x002d__x0020_Calcu> 
     
         </m:properties> 
     
        </content> 
     
        </entry> 
     
    </feed>

    正如你看到的我是能够成功地查询和的选择b来自列表中的其他字段并按标题过滤。不过,我想进一步过滤Delivery_x0020_Date为空(或空)。

    我周围搜索和一些人说,在日期过滤null不总是工作。但在我的情况比多一点,因为即使我尝试另一个关键过滤(Status_x0020__x002d__x0020_Calcu)将返回无效请求

    有什么类型的键,你可以筛选的要求? 谢谢

    回答

    0

    SharePoint 2013中的REST API不支持用于过滤列表项查询的空值。(请参阅此MSDN链接)

    您将不得不寻找一些其他的解决方法。然而,我们可以将CAML查询与REST API结合起来,以便在Javascript对象模型中获得所需的数据。请参阅此链接 - REST API to filter on null

    但我不确定c#代码。

    +0

    感谢您的回答。但在我的情况不是关于空值。以此为例: '... ccm/_api/Lists/GetByTitle('Circuit%20Deliveries')/ Items?$ filter = substringof('Circuit Ready for Production Use on',Status_x0020__x002d__x0020_Calcu)' 这也是返回错误的请求:S – Redespace

    相关问题