Microsoft Graph API - SendMail http 400 - 文档中的 API url 不起作用不起作用、文档、API、Graph

2023-09-06 17:30:36 作者:故事很久

我的应用程序使用 Microsoft Graph 发送电子邮件.我们遵循文档,这按预期工作了将近一年:

My application sends email using Microsoft Graph. We followed the documentation, this was working as expected for almost a year:

https://graph.microsoft.com/v1.0/users/me/microsoft.graph.sendmail

自 2019 年 3 月 8 日起,PROD 中的相同代码 sendmail API 开始失败,并出现 HTTP 400 - Bad Request:

Since 3/8/2019, the same code sendmail API in PROD started failing with the HTTP 400 - Bad Request:

{
  "error": {
    "code": "TargetIdShouldNotBeMeOrWhitespace",
    "message": "Id is malformed.",
    "innerError": {
      "request-id": "0de5a4eb-dac4-4d98-a4b4-178e503a6657",
      "date": "2019-03-19T17:16:20"
    }
  }
}

作为调查的一部分,我们发现示例中使用的 SendMail 文档的 URL 与 API 帮助部分不同.调用此 URL 时我们成功了:

As a part of the investigation, we found that the SendMail documentation has a different URL used in the examples than the API help section. We were successful when calling this URL:

https://graph.microsoft.com/v1.0/me/sendmail

问题:

显然,2019 年 3 月 8 日左右,Graph API 发生了一些更新,导致早期 URL 无法正常工作

Clearly looks like there was some update on the Graph API happened around 3/8/2019 that disabled working of the earlier URL

文档中有 2 个具有误导性/混淆性的 URL:一个是 API 帮助部分,一个是示例.截至目前,帮助部分中的 API URL 不再有效.这应该使用正确的 URL 来解决.

Documentation has 2 URL's that are misleading/confusing: one is the API help section and one in examples. As of now the API URL in the help section is no longer working. That should be fixed with the correct URL to be used.

为什么引入了像这样的重大更改,导致我们的应用程序的 PROD 中断?

Why was such breaking change like this introduced that caused a PROD outage for our application?

获取这些更改的官方渠道是什么?

What is the official channel to get these changes?

推荐答案

正确的 URI 是 https://graph.microsoft.com/v1.0/me/microsoft.graph.sendmail (不是 /me)

The correct URI is https://graph.microsoft.com/v1.0/me/microsoft.graph.sendmail (not /me)