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

如何使用Microsoft Graph API和OData筛选包含特定邮箱或姓名参会者的日历事件

Filtering Calendar Events by Nested Attendee Properties in Microsoft Graph API

Absolutely! You can absolutely filter calendar events to include only those with specific attendees (by name or email address) using Microsoft Graph API—your core approach with the OData any operator is correct, you just need to fix a couple of small issues in your request.

First: Fix the Invalid End Date

The immediate error you're seeing is likely caused by the invalid enddatetime value in your query: 2022-31-01T00:00:00.000Z. Date strings in Graph API follow the YYYY-MM-DD format, so January 31st should be written as 2022-01-31T00:00:00.000Z instead. This invalid date format will break your request before the filter even runs.

Correct Filter Syntax for Nested Attendee Properties

Once you fix the date, your nested any filter will work as expected. Here are the correct query formats for both email address and name filters:

Filter by Attendee Email Address

https://graph.microsoft.com/v1.0/me/calendarview?startdatetime=2022-01-01T00:00:00.000Z&enddatetime=2022-01-31T00:00:00.000Z&$select=attendees,subject&$filter=attendees/any(attendee: attendee/emailAddress/address eq 'peter.pan@neverland.org')

Filter by Attendee Name

https://graph.microsoft.com/v1.0/me/calendarview?startdatetime=2022-01-01T00:00:00.000Z&enddatetime=2022-01-31T00:00:00.000Z&$select=attendees,subject&$filter=attendees/any(attendee: attendee/emailAddress/name eq 'Peter Pan')

Key Notes:

  • URL Encoding: If you're manually constructing the URL, make sure to encode special characters (like spaces in the name) as %20. Most HTTP clients (like Postman, or SDKs) will handle this automatically, but if you're testing in a browser, you'll need to replace spaces with %20 (e.g., 'Peter%20Pan' instead of 'Peter Pan').
  • Combining Filters: To filter for events that have either the specified email OR name, use the or operator:
    $filter=attendees/any(attendee: attendee/emailAddress/address eq 'peter.pan@neverland.org' or attendee/emailAddress/name eq 'Peter Pan')
    
  • Permissions: Ensure your app has the required permissions (e.g., Calendars.Read or Calendars.ReadWrite) to access the user's calendar events.

Alternative: Use POST for Complex Filters

If your filter becomes too long for a GET request (or you want to avoid URL encoding headaches), you can use the POST method to the /calendarView/filter endpoint. Here's an example request body:

{
  "filter": "attendees/any(a: a/emailAddress/address eq 'peter.pan@neverland.org' or a/emailAddress/name eq 'Peter Pan')",
  "startDateTime": "2022-01-01T00:00:00.000Z",
  "endDateTime": "2022-01-31T00:00:00.000Z",
  "select": "attendees,subject"
}

After fixing the date format, your original nested filter should work perfectly to retrieve only events with the specified attendees.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.28 18:23:15