加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

search – 为Microsoft Graph创建一个与“contains”等效的过滤

发布时间:2020-12-14 04:05:53 所属栏目:Windows 来源:网络整理
导读:我需要为Microsoft Graph API创建一个$filter查询,用于搜索字符串中的特定单词(用户的显示名称). 例如,我希望能够找到名称中包含“Esteban”的所有用户: Luis Esteban Alphonse Esteban Esteban Luis Alphonse Esteban Luis 以下查询有效,但仅返回名称中以
我需要为Microsoft Graph API创建一个$filter查询,用于搜索字符串中的特定单词(用户的显示名称).

例如,我希望能够找到名称中包含“Esteban”的所有用户:

Luis Esteban
Alphonse Esteban
Esteban Luis
Alphonse Esteban Luis

以下查询有效,但仅返回名称中以“Esteban”开头的用户,而不是包含“Esteban”的用户:

https://graph.microsoft.com/v1.0/users?$filter=startswith(displayName,'Esteban')

我也尝试使用contains而不是startswith,但它给出了一个错误响应:

{ “error”: { “code”: “Request_BadRequest”,“message”: “An unknown function with name ‘contains’ was found. This may also be a key lookup on a navigation property,which is not allowed.”,“innerError”: { “request-id”: “e5ed5c30-4e62-4497-8976-1d38167e759d”,“date”: “2018-09-13T23:17:17” } } }

即使Microsoft Graph docs说他们支持OData 4.0,他们也说:

“The contains string operator is currently not supported on any Microsoft Graph resources.”

我还尝试了OData documentation和construction rules给出的其他命令,这些命令应该由过滤器和其他查询参数支持.

特别是我尝试了这些命令的组合:

startswith
endswith
indexof
substring

但没有成功.似乎MS Graph API除了startwith之外不支持任何东西.

我尝试了v1.0和API的beta端点.

有没有其他方法,MS Graph API支持的OData 4.0命令和/或查询参数的一些智能组合,允许搜索等效包含?

PS:您可以使用Graph Explorer here试用查询.

如您所知,Graph API现在不支持您的要求.我的建议是首先获取用户列表,然后进行内存过滤.这种方式也适用于其他不支持的Graph API.

同时,在User Voice投票支持existing feature request或提交新的.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读