chronolinq
chronolinq

Reputation: 103

Outlook API 555 Routing Failure when creating email draft

Our application has a feature that allows users to send emails directly from within the application using the Outlook Rest Api. We create a draft, optionally add attachments to it, and then send the email. This is done in C# using RestSharp.

Some of our users have run into issues when creating the draft. I have been unable to decipher what the error message really means, and if the correct answer is to just retry. (Some users manually try again and it appears to fail multiple times in quick succession). Those same users will then see successful emails sent later.

For reference, the api endpoint is: https://outlook.office.com/api/v2.0/me/messages and the reference documentation is here: https://msdn.microsoft.com/en-us/office/office365/api/mail-rest-operations#CreateNewDraft

Sample Rest Response:

{
  "Request": {
    "AlwaysMultipartFormData": false,
    "JsonSerializer": {
      "ContentType": "application/json"
    },
    "XmlSerializer": {
      "ContentType": "text/xml"
    },
    "UseDefaultCredentials": false,
    "Parameters": [
      {
        "Name": "Authorization",
        "Value": "Bearer [[REMOVED]]",
        "Type": 3
      },
      {
        "Name": "Content-Type",
        "Value": "application/json; charset=utf-8",
        "Type": 3
      },
      {
        "Name": "application/json",
        "Value": "[[MIME MESSAGE]]",
        "Type": 4
      },
      {
        "Name": "Accept",
        "Value": "application/json, application/xml, text/json, text/x-json, text/javascript, text/xml",
        "Type": 3
      }
    ],
    "Files": [],
    "Method": 1,
    "Resource": "api/v2.0/me/messages",
    "RequestFormat": 1,
    "OnBeforeDeserialization": {
      "Delegate": {},
      "method0": {
        "Name": "<.ctor>b__0",
        "AssemblyName": "RestSharp, Version=105.2.3.0, Culture=neutral, PublicKeyToken=null",
        "ClassName": "RestSharp.RestRequest",
        "Signature": "Void <.ctor>b__0(RestSharp.IRestResponse)",
        "Signature2": "System.Void <.ctor>b__0(RestSharp.IRestResponse)",
        "MemberType": 8,
        "GenericArguments": null
      }
    },
    "Timeout": 0,
    "ReadWriteTimeout": 0,
    "Attempts": 1
  },
  "ContentType": "",
  "ContentLength": 0,
  "ContentEncoding": "",
  "Content": "",
  "StatusCode": 555,
  "StatusDescription": "Routing Failure",
  "RawBytes": "",
  "ResponseUri": "https://outlook.office.com/api/v2.0/me/messages",
  "Server": "",
  "Cookies": [
    {
      "Comment": "",
      "Discard": false,
      "Domain": "outlook.office.com",
      "Expired": false,
      "Expires": "2019-01-18T04:09:17+00:00",
      "HttpOnly": true,
      "Name": "exchangecookie",
      "Path": "/",
      "Port": "",
      "Secure": false,
      "TimeStamp": "2018-01-18T04:09:17.2631733+00:00",
      "Value": "3b0a8015b9e24496bf28f9c6010e022a",
      "Version": 0
    },
    {
      "Comment": "",
      "Discard": false,
      "Domain": "outlook.office.com",
      "Expired": false,
      "Expires": "2018-01-18T04:24:17+00:00",
      "HttpOnly": false,
      "Name": "X-RouteRefreshCookie",
      "Path": "/",
      "Port": "",
      "Secure": false,
      "TimeStamp": "2018-01-18T04:09:17.2631733+00:00",
      "Value": "zoHNz87H0s/O0s7Hq8/Lxc/Gxc7IgbKot6+tz8u8vs/Py8mBqoGwlpvFzZrOnsybzJvSzsqcx9LLy8zO0seempzSzsqdy53MyJyZz83N2svPycfIyMmanM3Syp6dndLLzMfJ0p6cy83SycqdnMjNy52Zms+dwruei56dnoyauIqWm8XPm5nPzM/KmdKbz8eb0svPz8fSncbOz9LPmsybzZzNzcbPx5vay8/Jx8jIyZqczdLKnp2d0svMx8nSnpzLzdLJyp2cyM3LnZmaz53ay8+RnpKPjZvNz9GPjZCb0ZCKi5OQkJTRnJCS2svPz7/OzM7Jz8jNzc7KyMzHzMzLyMc=",
      "Version": 0
    }
  ],
  "Headers": [
    {
      "Name": "Set-Cookie",
      "Value": "exchangecookie=3b0a8015b9e24496bf28f9c6010e022a; expires=Fri, 18-Jan-2019 04:09:17 GMT; path=/; HttpOnly,X-RouteRefreshCookie=zoHNz87H0s/O0s7Hq8/Lxc/Gxc7Igayxzq+tzsi8vs/PzsyBqoGwlpvFzZrOnsybzJvSzsqcx9LLy8zO0seempzSzsqdy53MyJyZz83N2svPycfIyMmanM3Syp6dndLLzMfJ0p6cy83SycqdnMjNy52Zms+dwruei56dnoyauIqWm8XPm5nPzM/KmdKbz8eb0svPz8fSncbOz9LPmsybzZzNzcbPx5vay8/Jx8jIyZqczdLKnp2d0svMx8nSnpzLzdLJyp2cyM3LnZmaz53ay8+RnpKPjZvNz9GPjZCb0ZCKi5OQkJTRnJCS2svPz7/OzM7Jz8jNzc7KyMzHzMzLyMc=; expires=Thu, 18-Jan-2018 04:24:17 GMT; path=/,X-RouteRefreshCookie=zoHNz87H0s/O0s7Hq8/Lxc/Gxc7IgbKot6+tz8u8vs/Py8mBqoGwlpvFzZrOnsybzJvSzsqcx9LLy8zO0seempzSzsqdy53MyJyZz83N2svPycfIyMmanM3Syp6dndLLzMfJ0p6cy83SycqdnMjNy52Zms+dwruei56dnoyauIqWm8XPm5nPzM/KmdKbz8eb0svPz8fSncbOz9LPmsybzZzNzcbPx5vay8/Jx8jIyZqczdLKnp2d0svMx8nSnpzLzdLJyp2cyM3LnZmaz53ay8+RnpKPjZvNz9GPjZCb0ZCKi5OQkJTRnJCS2svPz7/OzM7Jz8jNzc7KyMzHzMzLyMc=; expires=Thu, 18-Jan-2018 04:24:17 GMT; path=/",
      "Type": 3
    },
    {
      "Name": "request-id",
      "Value": "ab8da322-62ac-4c32-b92b-accd590d7aaf",
      "Type": 3
    },
    {
      "Name": "X-CalculatedFETarget",
      "Value": "SN1PR17CU001.internal.outlook.com",
      "Type": 3
    },
    {
      "Name": "X-BackEndHttpStatus",
      "Value": "555,555",
      "Type": 3
    },
    {
      "Name": "X-FEProxyInfo",
      "Value": "SN1PR17CA0013.NAMPRD17.PROD.OUTLOOK.COM",
      "Type": 3
    },
    {
      "Name": "X-CalculatedBETarget",
      "Value": "SN1PR20MB0286.namprd20.prod.outlook.com",
      "Type": 3
    },
    {
      "Name": "x-ms-appId",
      "Value": "8410d572-e055-48e5-b2c7-869538daf671",
      "Type": 3
    },
    {
      "Name": "X-BEServerRoutingError",
      "Value": "Mailbox database change detected; moved from database 0fd6794b-0d64-4c64-be98-dc8157675f93 to 0df0305f-d08d-4008-b910-0e3d2c22908d",
      "Type": 3
    },
    {
      "Name": "X-DiagInfo",
      "Value": "SN1PR20MB0286",
      "Type": 3
    },
    {
      "Name": "X-BEServer",
      "Value": "SN1PR20MB0286",
      "Type": 3
    },
    {
      "Name": "X-FEServer",
      "Value": "SN1PR17CA0013,MWHPR04CA0046",
      "Type": 3
    },
    {
      "Name": "X-Powered-By",
      "Value": "ASP.NET",
      "Type": 3
    },
    {
      "Name": "X-MSEdge-Ref",
      "Value": "Ref A: A07C0D2FC267430AA8A2AEEEA095E277 Ref B: BAYEDGE0211 Ref C: 2018-01-18T04:09:17Z",
      "Type": 3
    },
    {
      "Name": "Date",
      "Value": "Thu, 18 Jan 2018 04:09:16 GMT",
      "Type": 3
    },
    {
      "Name": "Content-Length",
      "Value": "0",
      "Type": 3
    }
  ],
  "ResponseStatus": 1
}

Note: I've removed some details like the message itself and the bearer token. If it's necessary for debugging, I can obfuscate and include the information again.

UPDATE: It appears that the error code has changed to 503 Service Unavailable instead of 555 Routing Failure, but the details seem to be the same. The key response header is "X-BEServerRoutingError" that contains a value like "Mailbox database change detected; moved from database [guid] to [guid]". Based on the response from this SO question: Office365 API Error "Mailbox database change detected;", it appears that this is a known transient issue and the resolution is to just retry. There doesn't seem to be any guidance on amount of times to retry or anything like that. Still on the lookout for an answer that has proper guidance.

Upvotes: 1

Views: 262

Answers (1)

chronolinq
chronolinq

Reputation: 103

After a long support ticket conversation with Microsoft, their guidance was to add a retry policy.

My example above doesn't show it, but there is usually a header with the name of "X-Retry-After" that has an integer value that represents minutes. If the value is 0, it means to retry immediately.

After implementing the retry policy, we haven't seen anymore errors for roughly a week and a half.

Upvotes: 1

Related Questions