0
votes

Is there any sample code exists which has code written for creating office365 rest notification service contains push subscription, using client side libraries?

This link has given info but using rest calls. Is there anything using client libraries like using Notification class or Push subscription class?

We can write like following code to create subscription, but this add method is void !!!, so you will not get response and you will not get subscription id as well.

OutlookServicesClient client = new OutlookServicesClient(new Uri("https--//outlook.office.com/api/v2.0"), async () => { // Since we have it locally from the Session, just return it here. return token; });

            client.Context.SendingRequest2 += new EventHandler<Microsoft.OData.Client.SendingRequest2EventArgs>(
                (sender, e) => InsertXAnchorMailboxHeader(sender, e, email));


            PushSubscription subscribeme = new PushSubscription();
            subscribeme.NotificationURL = "https://mywebhook.azurewebsites.net/api/send/myNotifyClient";
            subscribeme.ChangeType = ChangeType.Deleted;
            subscribeme.ClientState = "AJFromPushSubcribtion_" + DateTime.Now.ToString();
            subscribeme.Resource = "https://outlook.office.com/api/v2.0/me/Events";
            subscribeme.SubscriptionExpirationDateTime = DateTime.Now.AddDays(1);

           await client.Me.Subscriptions.AddSubscriptionAsync(subscribeme);
1
from client side libraries we can use code as shown belowuser6012518

1 Answers

0
votes

Is there any sample code exists which has code written for creating office365 rest notification service contains push subscription, using client side libraries?

We can write like following code to create subscription, but this add method is void !!!, so you will not get response and you will not get subscription id as well.

I am not able to find code sample about creating office365 rest notification service. And I’ve tested the code you post at my side. After AddSubscriptionAsync method running successfully, you can get the response from the PushSubscription object you passed as parameter. So we can get the ID of the subscription via subscribeme.Id directly.