Ric*_*ero 11 search filter odata microsoft-graph
我需要$filter为Microsoft Graph API创建一个查询,以查找字符串中的特定单词(用户的显示名称).
例如,我希望能够找到名称中包含"Esteban"的所有用户:
Luis Esteban
Alphonse Esteban
Esteban Luis
Alphonse Esteban Luis
以下查询有效,但仅返回名称中以"Esteban"开头的用户,而不是包含"Esteban"的用户:
https://graph.microsoft.com/v1.0/users?$filter=startswith(displayName,'Esteban')
Run Code Online (Sandbox Code Playgroud)
我也尝试使用contains而不是startswith,但它给出了错误响应:
{"error":{"code":"Request_BadRequest","message":"找到名为'contains'的未知函数.这也可能是导航属性的键查找,这是不允许的."," innerError":{"request-id":"e5ed5c30-4e62-4497-8976-1d38167e759d","date":"2018-09-13T23:17:17"}}}
即使Microsoft Graph文档说他们支持OData 4.0,他们也说:
"任何Microsoft Graph资源目前都不支持包含字符串运算符."
我还尝试了OData文档给出的其他命令以及应该由其他查询参数支持的构造规则filter.
特别是我尝试了这些命令的组合:
startswith
的endsWith
的indexOf
子
但没有成功.似乎MS Graph API除了startswith任何东西都不支持任何东西.
我尝试了v1.0和API的beta端点.
有没有其他方法,MS Graph API支持的OData 4.0命令和/或查询参数的一些智能组合,允许搜索相当于?contains
PS:您可以在此处使用Graph Explorer尝试查询.
这似乎是唯一可以让您获得所需列表而无需亲自过滤所有用户的替代方案
https://graph.microsoft.com/v1.0/me/people?$search=Esteban&$top=100000\nRun Code Online (Sandbox Code Playgroud)\n根据此博客文章, microsoft-graph api 仅支持$filter等于
(eq)\n
不等于 (ne)\n
大于 (gt)\n
大于或等于 (ge)\n
小于 (lt),小于或等于 (le)\n
和 (and)\n
或 (or)\n
不 (not)\n
开头为\n
任何
\ n并且$search仅支持“messages\xe2\x80\x9d 和 \xe2” \x80\x9cperson\xe2\x80\x9d 实体。