【问题标题】:Mailgun error code 400 "'from' parameter is missing"Mailgun 错误代码 400“'from' 参数丢失”
【发布时间】:2022-03-08 18:57:20
【问题描述】:

我正在尝试使用 mailgun API 进行发布请求并发送消息,但我似乎无法弄清楚如何快速格式化消息数据。我上传的数据中的 from 参数存在问题。

request.setValue("Basic \(base64Credentials)", forHTTPHeaderField: "Authorization")
        request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")

    let data = "from: Foo <info@sandbox(sandboxInfo).mailgun.org>&to: <foo@me.com>&subject:Hello&text:Testing Mailgun"
        request.httpBody = data.data(using: String.Encoding.ascii)

回复:

);
    "Cache-Control" =     (
        "no-store"
    );
    Connection =     (
        "keep-alive"
    );
    "Content-Length" =     (
        46
    );
    "Content-Type" =     (
        "application/json"
    );
    Date =     (
        "Wed, 03 Mar 2021 01:05:39 GMT"
    );
    Server =     (
        nginx
    );
} }
response code = 400
data {
  "message": "'from' parameter is missing"
}

【问题讨论】:

  • 通过找出 HTTP 状态码 400 的含义来帮助自己。
  • 我知道代码的含义,它告诉我响应消息中的错误。 from 参数错误,但我不知道正确的参数是什么。
  • 您必须提交所有需要的参数并正确设置MG。这个完整的例子(包括vb,net代码)可以帮助你:stackoverflow.com/questions/68150905/…

标签: swift http post request mailgun


【解决方案1】:

我一直在尝试从 mailgun 访问这个 API,似乎文档有点误导。使用https://api.mailgun.net/v3/xxxxx.domain/messages 时,似乎body 应该是一种参数形式,以便API 识别它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-14
    • 2019-12-22
    • 2022-12-12
    • 1970-01-01
    • 2015-12-23
    • 1970-01-01
    相关资源
    最近更新 更多