You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Microsoft Graph中按日历事件的location/displayName筛选?

解决Microsoft Graph API筛选日历事件location/displayName的问题

我之前也碰到过类似的情况,咱们一步步来排查解决:

1. 注意属性名的大小写问题

Graph API的属性名是严格区分大小写的,你写的location/displayname里的displayname要改成**displayName**(N是大写的),这是最容易踩的坑。

2. 处理空值避免报错

有些日历事件可能没设置location属性,直接对location/displayName用startsWith会触发错误。建议先判断该属性不为null,再进行筛选。

修正后的查询示例

结合上面两个点,你的查询应该调整成这样:

/me/calendarview?startdatetime=01-01-2019&enddatetime=12-31-2019&$filter=(isorganizer eq true) and (location/displayName ne null) and startsWith(location/displayName,'Conference')&$top=100&$select=subject,organizer,attendees,start,end,location&$orderby=start/dateTime

额外排查小技巧

  • 如果还是有问题,可以先去掉$filter参数,请求几个事件,确认返回的location结构里确实存在displayName字段;
  • 也可以先用精确匹配测试:$filter=location/displayName eq 'Conference Room - Baker',确认能正常返回结果后,再换成startsWith。

内容的提问来源于stack exchange,提问作者Glenn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:51:28