【发布时间】:2020-01-03 14:45:32
【问题描述】:
我正在尝试使用 Mailgun 和 Alarmofire 从我的 iOS 应用程序发送邮件我发现 this piece of code 但 Xcode 生成错误:
无法将“[String : String]”类型的值转换为预期参数 输入“HTTPHeaders?”
代码:
let parameters = [
"from": "sender@whatyouwant.com",
"to": "anyRecipient@example.com",
"subject": "Subject of the email",
"text": "This is the body of the email."]
let header = [
"Authorization": "Basic MY-API-KEY",
"Content-Type" : "application/x-www-form-urlencoded"]
let url = "https://api.mailgun.net/v3/MY-DOMAIN/messages"
Alamofire.request(url,
method: .post,
parameters: parameters,
encoding: URLEncoding.default,
headers: header)
.responseJSON { response in
print("Response: \(response)")
}
有什么建议吗?
【问题讨论】: