Office 365 EWS does not return X-BackendOverrideCookie RRS feed

  • Question

  • Office 365 does not return the X-BackendOverrideCookie in response headers.

    I set the X-AnchorMailbox and X-PreferServerAffinity in the request headers properly. This does not trigger X-BackendOverrideCookie to be returned, as it says in MSDN. Why is this happening?

    Meanwhile, I tried the same thing with an on-premise Exchange 2016. Here I don't even set the X-AnchorMailbox and X-PreferServerAffinity and I get back the X-BackendOverrideCookie in each response. This is not good either, since I need to manage affinity for groups of pull and push notifications, and I need to set this cookie when I want, and not have it set always by default.


    The flow goes like this. I am sending the subscribe request using JS. For that purpose I use lather library (npm, can't post a link) to wrap my request into SOAP format.

    This is how that operation looks like:

    var impersonate = ‘’
    var subscribe = {
             "m:Subscribe": {
                        "m:PullSubscriptionRequest": {
                            "t:FolderIds": {
                                "t:DistinguishedFolderId": {
                                    attributes: [{
                                        'Id': this.distinguishedFolderId
                            "t:EventTypes": [{
                                "t:EventType": "CreatedEvent"
                            }, {
                                "t:EventType": "DeletedEvent"
                            }, {
                                "t:EventType": "ModifiedEvent"
                            "t:Timeout": "10"
    soapHeader = {
                    “t:ExchangeImpersonation": {
                       "t:ConnectingSID": {
                           't:SmtpAddress': impersonate
                    body : requestName,          
                    headers : {
                        Authorization : lather.basicAuth(this.username, this.password),            
                        'X-AnchorMailbox': impersonate,
                        'X-PreferServerAffinity': true
                    additionalNamespaces : [
                    soapHeader : soapHeader,
                    method : 'POST',
                    url : ‘',
                }, function(error, res, body) {
                   // Process the response

    When this executes the request is formed and sent out. When I look at the raw request being sent out, I confirm that the headers are in place.

    { Authorization: 'Basic c29m…’, (shortened just in case)
    'X-AnchorMailbox': ‘', (fake mail)
    'X-PreferServerAffinity': true,
    'Content-Length': 971,
    'Content-Type': 'text/xml; charset=utf-8',
    host: '' }

    Then I get back the following response from Office.

    The body of the response: (shortened Ids, just in case)

    <?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s=""><s:Header><h:ServerVersionInfo MajorVersion="15" MinorVersion="1" MajorBuildNumber="693" MinorBuildNumber="12" Version="V2016_10_10" xmlns:h="" xmlns:xsd="" xmlns:xsi=""/></s:Header><s:Body><m:SubscribeResponse xmlns:m="" xmlns:xsd="" xmlns:xsi="" xmlns:t=""><m:ResponseMessages><m:SubscribeResponseMessage ResponseClass=“Success”><m:ResponseCode>NoError</m:ResponseCode><m:SubscriptionId>KQB2aTFwcjA…wucsA==</m:SubscriptionId><m:Watermark>AQAAAFQ+2wmbaZF…JAAAAAAA=</m:Watermark></m:SubscribeResponseMessage></m:ResponseMessages></m:SubscribeResponse></s:Body></s:Envelope>
    The headers of the response are: (shortened Ids, cookie)
    { 'cache-control': 'private',
    'transfer-encoding': 'chunked',
    'content-type': 'text/xml; charset=utf-8',
    server: 'Microsoft-IIS/8.5',
    'request-id': ‘2881ab3…1ec461’,
    'x-calculatedbetarget': '',
    'x-backendhttpstatus': '200',
    'set-cookie': [ ‘exchangecookie=d8f8…1e8; expires=Sat, 28-Oct-2017 08:41:27 GMT; path=/; HttpOnly' ],
    'x-ewshandler': 'Subscribe',
    'x-aspnet-version': '4.0.30319',
    'x-diaginfo': 'VI1PR0501MB2096',
    'x-beserver': 'VI1PR0501MB2096',
    'x-powered-by': 'ASP.NET',
    'x-feserver': 'VI1PR0901CA0093',
    date: 'Fri, 28 Oct 2016 08:41:26 GMT' }

    As you can see I only get the exchange cookie, and no X-BackendOverrideCookie. Any ideas on what is going on? Am I doing something wrong?

    Edit 2: I also tried this with EWSEditor. Set the two headers, and made a pull subscription request. I get the same result as here.

    Tuesday, November 1, 2016 8:27 AM