我正在使用 Microsoft Graph API 的 Beta 版来访问 SharePoint 列表项。我正在尝试过滤创建日期的项目。
我调用的 URI 是:
https://graph.microsoft.com/beta/sites/{site-id}/lists/{list-id}/items/?$filter=createdDateTime gt '2017-09-20T00:00:00'
我最终遇到以下错误:
{
"error": {
"code": "BadRequest",
"message": "A binary operator with incompatible types was detected. Found operand types 'Edm.DateTimeOffset' and 'Edm.String' for operator kind 'GreaterThan'.",
"innerError": {
"request-id": "4bdec409-885c-46ee-b3b6-df2c43f997ac",
"date": "2017-09-27T08:11:22"
}
}
}
我搜索了很多有关使用日期类型和 OData 的问题,但没有一个解决方案有效。此日期格式适用于 API 中的其他实体。所以这似乎是过滤日期的正确语法。我做错了什么还是 Graph API 中的错误?
在大多数情况下,MS Graph API 的测试版已被弃用。我建议使用 v1.0。
您可以采用的一种解决方案是调用 Get listItem 来获取 listItem 的特定值:
GET /sites/{site-id}/lists/{list-id}/items/{item-id}?expand=fields(select=Column1,Column2)
https://learn.microsoft.com/en-us/graph/api/listitem-get?view=graph-rest-1.0&tabs=http