【发布时间】:2018-06-13 22:15:12
【问题描述】:
from 参数在正文中。为什么会出现这个错误?
export class EmailService {
constructor(private http: HttpClient) {}
sendMailgunMessage() {
const options = {
headers: new HttpHeaders({
'Content-Type': 'application/x-www-form-urlencoded'
})
};
const body = {
username: 'api',
password: 'key-xxx',
from: '<hello@app.xxx.com>',
to: 'xxx@xxx.com',
subject: 'Subject text',
text: 'Body text',
multipart: true
};
return this.http.post('https://api.mailgun.net/v3/app.xxx.com/messages', body, options);
}
}
当我订阅 sendMailgunMessage 函数时,我在浏览器中收到错误消息:HttpErrorResponse {headers: HttpHeaders, status: 400, statusText: "BAD REQUEST"...error : {消息:“'from'参数丢失”}
已添加 xxx 以保护敏感信息。我还尝试将 API 密钥添加到 URL,但这给出了相同的“来自”错误。
【问题讨论】:
标签: angular typescript http mailgun