【发布时间】:2018-02-17 07:03:20
【问题描述】:
我正在尝试从 SharePoint 列表中查询一些信息。现在,我正在尝试使用 odata 来获取它。我的问题是,由于某种原因,$filter 无法使用该列表中的所有键:S。这是一个例子:
这工作正常:
- ...ccm/_api/Lists/GetByTitle('Circuit%20Deliveries')/Items?$filter=Title eq 'AUG'
但是这个不起作用(HTTP 400 错误请求)
- ...ccm/_api/Lists/GetByTitle('Circuit%20Deliveries')/Items?$filter=Delivery_x0020_Date eq null
尽管如此,字段名称还可以,因为我可以使用具有相同字段名称的 select 和 orderby。这是 IE 中名为 AUG 的 2 个“标题”的 XML 输出:
...ccm/_api/Lists/GetByTitle('Circuit%20Deliveries')/Items?$filter=Title 情商 'AUG'&$select=Title,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>
如您所见,我能够成功查询并从列表中选择两个字段并按标题过滤。不过,我想进一步过滤 Delivery_x0020_Date 为空(或 null)。
我四处搜索,有人说在日期上按 null 过滤并不总是有效。但在我的情况下不止于此,因为即使我尝试通过另一个键(Status_x0020__x002d__x0020_Calcu)进行过滤,它也会返回 Bad Request
对可以过滤的键类型有要求吗? 谢谢
【问题讨论】:
标签: c# rest sharepoint filter odata