none
EWS push notifications with Web API Listner RRS feed

  • Question

  • I am trying to subscribe to exchange push notifications and trying to listen to it in a RESTful service (WebAPI). I have this working in a console app. I am doing the subscription like this.

              _service = new ExchangeService(ExchangeVersion.Exchange2010_SP1)
                {
                    UseDefaultCredentials = true,
                    TraceEnabled = true,
                    TraceFlags = TraceFlags.All
                };
                var emailAccount = "account@test.com";
                _service.AutodiscoverUrl(emailAccount, RedirectionUrlValidationCallback);
    
                var url = new Uri("http://FQDN(Local system)/Listner/api/ExchangeListner");
                var inboxFolderId = new FolderId(WellKnownFolderName.Inbox, emailAccount);
                var folders = new List<FolderId> {inboxFolderId};
                var subscription = _service.SubscribeToPushNotifications(folders, url, 1, null, EventType.NewMail);
                _pushSubscriptionId = subscription.Id;

    at this moment I have a bare minimum on my post method in the exchange listener controller.

    // POST: api/ExchangeListner
        public void Post(object request)
        {
            if (request != null)
            {
                var type = request.GetType();
            }
         }

    When in debug mode, on a new email, I can step into the post method. but the request is always null. I tried doing this too, but no luck

        // POST: api/ExchangeListner
        public void Post(SendNotificationRequest request)
        {
            if (request != null)
            {
                var type = request.GetType();
            }
         }

    what am I am doing wrong?


    Thursday, October 8, 2015 8:25 PM

All replies