包含 Microsoft Graph 查询上的筛选器不起作用不起作用、Microsoft、Graph

2023-09-06 17:37:58 作者:孤独患者

我正在尝试在/users 查询中使用 contains 过滤器,例如:https://graph.microsoft.com/v1.0/users?$filter=包含(显示名称,'Garth')

I'm trying to user the contains filter on a /users query, like this for example: https://graph.microsoft.com/v1.0/users?$filter=contains(displayName, 'Garth')

但是,这会导致 BadRequest 响应说发现了一个名为 'contains' 的未知函数.这也可能是对导航属性的键查找,这是不允许的."

However, this results in a BadRequest response saying "An unknown function with name 'contains' was found. This may also be a key lookup on a navigation property, which is not allowed."

根据 OData 4.0 规范,包含过滤器应该可用.有没有办法在用户列表上使用包含过滤器?

According to the OData 4.0 specs, the contains filter should be available though. Is there a way to use a contains filter on a list of users?

推荐答案

contains 功能对用户不可用.startsWith 是可用的.例如https://graph.microsoft.com/v1.0/users?$filter=startswith(displayName,'Garth').

The contains function is not available for users. startsWith is available though. e.g. https://graph.microsoft.com/v1.0/users?$filter=startswith(displayName,'Garth').