Outlook 未收到包含自定义属性的日历事件的更改通知

Outlook 未收到包含自定义属性的日历事件的更改通知,outlook,microsoft-graph-api,outlook-restapi,change-notification,Outlook,Microsoft Graph Api,Outlook Restapi,Change Notification,我们希望从用户的Outlook日历接收更改通知。我们希望将这些通知仅限于包含自定义属性的日历项 创建日历事件的代码 private static async Task<Event> CreateAppointmentAsync(GraphServiceClient graphClient) { var newEvent = new Microsoft.Graph.Event { Subject = "Test Calendar Appoin

我们希望从用户的Outlook日历接收更改通知。我们希望将这些通知仅限于包含自定义属性的日历项

创建日历事件的代码

private static async Task<Event> CreateAppointmentAsync(GraphServiceClient graphClient)
{

    var newEvent = new Microsoft.Graph.Event
    {
        Subject = "Test Calendar Appointmnt",
        Start = new DateTimeTimeZone() { TimeZone = TimeZoneInfo.Local.Id, DateTime = "2020-11-21T21:00:00" },
        End = new DateTimeTimeZone() { TimeZone = TimeZoneInfo.Local.Id, DateTime = "2020-11-21T22:00:00" },
        Location = new Location() { DisplayName = "Somewhere" },
        Body = new ItemBody { Content = "Some Random Text" },

    };

    Microsoft.Graph.Event addedEvent;
    try
    {
        newEvent.SingleValueExtendedProperties = new EventSingleValueExtendedPropertiesCollectionPage();
        newEvent.SingleValueExtendedProperties.Add(new SingleValueLegacyExtendedProperty { Id = "String {00020329-0000-0000-C000-000000000046} Name CompanyID", Value = "12345" });


        addedEvent = await graphClient.Me.Calendar.Events.Request().AddAsync(newEvent);

   

    }
    catch (Exception e)
    {
        throw e;
    }


    return addedEvent;

  

}

var subscription = new Subscription
{
    ChangeType = "created",
    NotificationUrl ="<OUR-URL>",                                   
    Resource = "me/events/?$filter=singleValueExtendedProperties/any(ep: ep/id eq 'String {00020329-0000-0000-C000-000000000046} Name CompanyID' and ep/value ne null)",
    ExpirationDateTime = DateTimeOffset.Parse("2020-11-13T18:23:45.9356913Z"),
    ClientState = "custom_data_state",
    LatestSupportedTlsVersion = "v1_2"
};

private静态异步任务CreateAppointmentAsync(GraphServiceClient graphClient)
{
var newEvent=new Microsoft.Graph.Event
{
Subject=“测试日历指定”,
Start=new datetimezone(){TimeZone=TimeZoneInfo.Local.Id,DateTime=“2020-11-21T21:00:00”},
End=new datetimezone(){TimeZone=TimeZoneInfo.Local.Id,DateTime=“2020-11-21T22:00:00”},
Location=新位置(){DisplayName=“某处”},
Body=newitembody{Content=“Some Random Text”},
};
Microsoft.Graph.Event AddEvent;
尝试
{
newEvent.SingleValueExtendedProperties=新事件SingleValueExtendedPropertiesCollectionPage();
newEvent.SingleValueExtendedProperties.Add(新的SingleValueLegacyExtendedProperty{Id=“String{00020329-0000-0000-C000-0000000000 46}名称CompanyID”,Value=“12345”});
addedEvent=await graphClient.Me.Calendar.Events.Request().AddAsync(newEvent);
}
捕获(例外e)
{
投掷e;
}
返回加法器;
}
订阅代码片段

private static async Task<Event> CreateAppointmentAsync(GraphServiceClient graphClient)
{

    var newEvent = new Microsoft.Graph.Event
    {
        Subject = "Test Calendar Appointmnt",
        Start = new DateTimeTimeZone() { TimeZone = TimeZoneInfo.Local.Id, DateTime = "2020-11-21T21:00:00" },
        End = new DateTimeTimeZone() { TimeZone = TimeZoneInfo.Local.Id, DateTime = "2020-11-21T22:00:00" },
        Location = new Location() { DisplayName = "Somewhere" },
        Body = new ItemBody { Content = "Some Random Text" },

    };

    Microsoft.Graph.Event addedEvent;
    try
    {
        newEvent.SingleValueExtendedProperties = new EventSingleValueExtendedPropertiesCollectionPage();
        newEvent.SingleValueExtendedProperties.Add(new SingleValueLegacyExtendedProperty { Id = "String {00020329-0000-0000-C000-000000000046} Name CompanyID", Value = "12345" });


        addedEvent = await graphClient.Me.Calendar.Events.Request().AddAsync(newEvent);

   

    }
    catch (Exception e)
    {
        throw e;
    }


    return addedEvent;

  

}

var subscription = new Subscription
{
    ChangeType = "created",
    NotificationUrl ="<OUR-URL>",                                   
    Resource = "me/events/?$filter=singleValueExtendedProperties/any(ep: ep/id eq 'String {00020329-0000-0000-C000-000000000046} Name CompanyID' and ep/value ne null)",
    ExpirationDateTime = DateTimeOffset.Parse("2020-11-13T18:23:45.9356913Z"),
    ClientState = "custom_data_state",
    LatestSupportedTlsVersion = "v1_2"
};

var订阅=新订阅
{
ChangeType=“已创建”,
通知URL=“”,
Resource=“me/events/?$filter=singleValueExtendedProperties/any(ep:ep/id eq'String{00020329-0000-0000-C000-0000000000 46}Name CompanyID'和ep/value ne null)”,
ExpirationDateTime=DateTimeOffset.Parse(“2020-11-13T18:23:45.9356913Z”),
ClientState=“自定义数据状态”,
LatestSupportedTLVersion=“v1_2”
};

订阅已成功创建,但未针对包含上述特定自定义属性的项目发送通知。

结果表明,我只是捕获了“已创建”通知。我忽略了添加“更新”和“删除”

我正在用日历中已经存在的事件进行测试。没有触发任何事件,因为我没有创建订阅来检测更新和删除

以下是更正后的订阅:

var subscription = new Subscription
{
    ChangeType = "created,updated,deleted",
    NotificationUrl ="<OUR-URL>",                                   
    Resource = "me/events/?$filter=singleValueExtendedProperties/any(ep: ep/id eq 'String {00020329-0000-0000-C000-000000000046} Name CompanyID' and ep/value ne null)",
    ExpirationDateTime = DateTimeOffset.Parse("2020-11-13T18:23:45.9356913Z"),
    ClientState = "custom_data_state",
    LatestSupportedTlsVersion = "v1_2"
};
var订阅=新订阅
{
ChangeType=“已创建、更新、删除”,
通知URL=“”,
Resource=“me/events/?$filter=singleValueExtendedProperties/any(ep:ep/id eq'String{00020329-0000-0000-C000-0000000000 46}Name CompanyID'和ep/value ne null)”,
ExpirationDateTime=DateTimeOffset.Parse(“2020-11-13T18:23:45.9356913Z”),
ClientState=“自定义数据状态”,
LatestSupportedTLVersion=“v1_2”
};

@Shiva MSFTIdentity,根据这篇文章,可以根据自定义事件过滤通知。日历事件不可能吗?