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 : {message:“'from'参数缺失”}
已添加xxx以保护敏感信息。我还尝试将API密钥添加到URL中,但是这给出了相同的“发送”错误。
答案 0 :(得分:0)