2017-09-08 39 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

    相關問題