Outlook API 555 创建电子邮件草稿时路由失败

Outlook API 555 Routing Failure when creating email draft

我们的应用程序具有一项功能,允许用户使用 Outlook Rest Api 直接从应用程序内发送电子邮件。我们创建一个草稿,可以选择向其中添加附件,然后发送电子邮件。这是在 C# 中使用 RestSharp 完成的。

我们的一些用户在创建草稿时遇到了 运行 问题。我一直无法破译错误消息的真正含义,如果正确答案是重试。 (有些用户手动重试,似乎连续多次失败)。这些相同的用户随后将看到成功发送的电子邮件。

作为参考,api 端点是: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

示例休息响应:

{
  "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
}

注意:我删除了一些细节,例如消息本身和不记名令牌。如果需要调试的话,我可以重新混淆并包含信息。

更新:错误代码似乎已更改为 503 Service Unavailable 而不是 555 Routing Failure,但细节似乎相同。关键响应 header 是 "X-BEServerRoutingError",其中包含类似 "Mailbox database change detected; moved from database [guid] to [guid]" 的值。根据这个 SO 问题的响应:Office365 API Error "Mailbox database change detected;",这似乎是一个已知的暂时性问题,解决方法是重试。似乎没有关于重试次数或类似内容的任何指导。仍在寻找具有适当指导的答案。

在与 Microsoft 进行了长时间的支持票对话后,他们的指导是添加重试策略。

我上面的例子没有显示它,但通常有一个 header 名称为 "X-Retry-After",它有一个代表分钟的整数值。如果值为0,表示立即重试。

实施重试政策后,大约一个半星期以来我们再也没有看到错误。