首页 > 解决方案 > UserInfo={NSDebugDescription=字符 0 周围的值无效。}

问题描述

尝试使用 MailGun 从 iOS 发送电子邮件的图像。我已经设置了一个试用帐户进行测试。我正在使用此代码发送:

 let parameters = [
               "from": "my@mail.com",
               "to": "you@mail.com",
               "subject": "Hello from Swift",
               "text": "Mail sendt from MailGun"]
           let header : HTTPHeaders = [
               "Authorization": "myAPIKey",
               "Content-Type" : "application/x-www-form-urlencoded"]

           let url = "My URL"
           AF.request(url,
                      method: .post,
                      parameters: parameters,
                      encoding: URLEncoding.default,
                      headers: header)
               .responseJSON { response in
                   print("Response: \(response)")
           }    

这给出了错误:

> Response:
> failure(Alamofire.AFError.responseSerializationFailed(reason:
> Alamofire.AFError.ResponseSerializationFailureReason.jsonSerializationFailed(error:
> Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around
> character 0." UserInfo={NSDebugDescription=Invalid value around
> character 0.})))    

这哪里出错了?

标签: swiftalamofiremailgun

解决方案


推荐阅读