通过扩展属性过滤CalendarView时没有结果

问题描述

我正在使用Microsoft Graph C#SDK从用户检索某些日历事件。使用方法

var calendarView = await graphClient.Users[mail].CalendarView.Request(
    new List<QueryOption>()
    {
        new QueryOption("startDateTime",$"{DateTime.Now.AddMonths(-1).ToString("s")}"),new QueryOption("endDateTime",$"{DateTime.Now.AddMonths(1).ToString("s")}")
    })
    .Expand("singleValueExtendedProperties($filter=id eq 'String {MY-GUID-HERE} Name Creator')")
    .GetAsync();

工作正常。我获得了时间范围内的事件以及自定义属性。现在,我只想从具有以下属性的列表中捕获此事件:

Microsoft.Graph.EventSingleValueExtendedPropertiesCollectionPage
Id: 'String {MY-GUID-HERE} Name Creator'
Value: 'SyncUser'

因此,在文档之后,我添加Filter()方法

var calendarView = await graphClient.Users[mail].CalendarView.Request(
    new List<QueryOption>()
    {
        new QueryOption("startDateTime",$"{DateTime.Now.AddMonths(1).ToString("s")}")
    })
    .Filter("singleValueExtendedProperties/Any(ep: ep/id eq 'String {MY-GUID-HERE} Name Creator' and ep/value eq 'SyncUser')")
    .Expand("singleValueExtendedProperties($filter=id eq 'String {MY-GUID-HERE} Name Creator')")
    .GetAsync();

,我得到零结果。我确实检查了查询,GUID,值,复制了值以及所有内容。但是,查询仍然不会产生任何结果。但是,注释掉Filter方法会返回带有我要查找的项目的整个列表。

更新:我从第一个程序(仅Expand())公开了HttpRequestMessage,因此可以在Graph Explorer中使用该url。尽管我的C#程序使用相同的url,但使用Graph还是遇到以下错误

GET https://graph.microsoft.com/v1.0/me/calendarview?startdatetime=2020-09-02T07:34:05.397Z&enddatetime=2020-10-09T07:34:05.397Z&$expand=singleValueExtendedProperties($filter=id%20eq%20'String%20%7BMY-GUID-HERE%7D%20Name%20Creator')

{
    "error": {
        "code": "BadRequest","message": "Parsing OData Select and Expand Failed: Found an unbalanced bracket expression.","innerError": {
            "date": "2020-10-02T07:38:40","request-id": "50f365a4-d936-4173-a650-ed7f318da08f","client-request-id": "c4669369-61f5-016d-cb2c-efd1b738c5af"
        }
    }
}

第二个(扩展和过滤器):

GET https://graph.microsoft.com/v1.0/me/calendarView?startDateTime=2020-08-02T09:41:09&endDateTime=2020-12-02T09:41:09&$filter=singleValueExtendedProperties/Any(ep: ep/id eq 'String {MY-GUID-HERE} Name Creator' and ep/value eq 'SyncUser')&$expand=singleValueExtendedProperties($filter=id eq 'String {MY-GUID-HERE} Name Creator')    

返回完全相同的错误消息。

解决方法

OData查询参数存在一些限制,其中“ {Expand”和“ Filter”无法按Known Issues中的指定一起使用。请提出一个功能请求,以在Microsoft Graph Feedback Forum中指定此API调用,以便产品团队将来可以实现它。