我正在使用 JavaScript 发出 POST 请求以使用 xhr 创建到 Office 365 的消息(或使用 Faraday gem 发出 POST 请求 - Ruby on Rails)。我的流程是将文件编码为 base64 并创建一个包含所有附件的 JSON(编码) 然后发布到https://outlook.office.com/api/v1.0/me/sendmail
.
var endpointUrl = "https://outlook.office.com/api/v1.0/me/sendmail";
var xhr = new XMLHttpRequest();
xhr.open("POST", endpointUrl);
xhr.setRequestHeader("Authorization", "Bearer " + token);
xhr.setRequestHeader("content-type", "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8");
xhr.send(JSON.stringify(result));
}
此代码可以发送带有大约 22,5MB 附件的消息,但如果所有附件都超过 23MB,我会收到 404 错误响应,并且 cosole 写道:
XMLHttpRequest 无法加载 https://outlook.office.com/api/v1.0/me/sendmail。请求的资源上不存在“Access-Control-Allow-Origin”标头。因此,不允许访问源“ http://localhost:3000 ”。响应具有 HTTP 状态代码 404。
Alr 设置message size restrictions
为 max153600
有人可以帮我吗?谢谢 !