【问题标题】:'error: {message: "'from' parameter is missing"}' using Mailgun REST API from Angular 6 app'错误:{消息:“'from'参数丢失”}'使用来自Angular 6应用程序的Mailgun REST API
【发布时间】: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


    【解决方案1】:
    1. 我建议您使用 POSTMAN 测试您的 api(使用您的函数创建实例并在 POSTMAN 中使用“GET”查看结果),然后查看响应。您也可以在 POSTMAN 中使用“POST”来查看它是否有效。
    2. 是否报告其他错误,例如缺少其他参数。如果是这样,原因可能是您在发布时实际上没有传递任何数据。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-19
      • 2014-10-11
      相关资源
      最近更新 更多