如何在 Microsoft Graph API 中使用过滤器来获取 SharePoint 项目?

Deb*_*osh 4 sharepoint sharepoint-online boomi microsoft-graph-api

在这里,我试图根据创建日期过滤数据。一开始我在 Graph Explorer 中尝试过,它正在工作。

https://graph.microsoft.com/v1.0/me/messages?$filter=createdDateTime ge 2017-09-04&$select=subject,lastModifiedDateTime
Run Code Online (Sandbox Code Playgroud)

现在尝试在戴尔 Boomi 中实现相同的功能。这是拉出所有项目的资源路径:sites/{id}.sharepoint.com:/sites/{id}:/lists/{list_id}/items 它工作正常。

之后我添加过滤条件:

sites/{id}.sharepoint.com:/sites/{id}:/lists/{list_id}/items?$filter=lastModifiedDateTime ge 2017-09-04&$select=email,displayName
Run Code Online (Sandbox Code Playgroud)

这是错误。这是错误消息:

<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request</h2>
<hr><p>HTTP Error 400. The request is badly formed.</p>
Run Code Online (Sandbox Code Playgroud)

有人可以对此提供帮助,如何解决此问题?这是示例数据。

> {   "@odata.context":
> "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.list)(&#39;1334af71-5b7a-4276-a8d8-c3f3f129051d&#39;)/items",
> "value": [
>     {
>       "@odata.etag": "&quot;ef6e961c-a956-400e-a77d-f044d2e0b894,8&quot;",
>       "createdDateTime": "2018-05-24T13:38:10Z",
>       "eTag": "&quot;ef6e961c-a956-400e-a77d-f044d2e0b894,8&quot;",
>       "id": "3",
>       "lastModifiedDateTime": "2018-06-18T10:24:27Z",
>       "webUrl": "https://{id}.sharepoint.com/sites/{id}/Doc%20Interfaces/757391.pdf",
>       "createdBy": {
>         "user": {
>           "email": "abc@abc.COM",
>           "id": "173abc",
>           "displayName": "abc"
>         }
>       },
>       "lastModifiedBy": {
>         "user": {
>           "email": "xyz@abc.COM",
>           "id": "234xyz",
>           "displayName": "xyz"
>         }
>       },
>       "parentReference": {
>         "id": "03fe-16595a0da875"
>       },
>       "contentType": {
>         "id": "0x01"
>       },
>       "fields@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.list)(&#39;1334f71-c3f3f129&#39;)/items(&#39;3&#39;)/fields/$entity",
>       "fields": {
>         "@odata.etag": "&quot;ef6e961-f044d2e0b894,8&quot;",
>         "FileLeafRef": "757391.pdf",
Run Code Online (Sandbox Code Playgroud)

小智 5

简答

使用自动生成的 SharePoint 列表项字段创建修改

/items?expand=fields&$filter=fields/Modified gt '2018-01-01'
Run Code Online (Sandbox Code Playgroud)

重要的提示

要对这些字段执行过滤查询,您必须:

  • 索引这些列(请参阅此处的方法
  • 或者根据您的请求设置“Prefer: HonorNonIndexedQueriesWarningMayFailRandomly”标头(Microsoft 不推荐)

说明

似乎不支持对图形端点返回的值(例如 lastModifiedDateTime、createdDateTime 等)进行过滤,因为/items&$filter=lastModifiedDateTime ge '2018-01-01' 之类的请求将返回“无效过滤器条款”错误。