我正在使用alamofire第三方库上传图片,这里我的代码通过服务器上传图像但总是出现同样的错误
responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.jsonSerializationFailed(错误 Domain = NSCocoaErrorDomain Code = 3840"字符周围的值无效 0" UserInfo = {NSDebugDescription =字符0周围的值无效。}))▿失败:AFError ▿responseSerializationFailed:ResponseSerializationFailureReason
请帮帮我
self.uploadRequest = Alamofire.upload(fileData, to: url, method: .put, headers: nil).responseJSON(completionHandler: { (result) in
completionHandler(result)
}).downloadProgress(closure: { (progress) in
print(progress.fractionCompleted)
})
答案 0 :(得分:0)
使用Alamofire的 responseJSON 时出错:
"Invalid value around character 0."
当您的Web服务的结果不是JSON格式时,非常常见。
通过记录回复正文或甚至通过登录浏览器或邮递员(镀铬扩展程序)来检查您的网络服务结果。
几乎100%肯定你会发现除了预期的JSON之外的东西(例如html 404/500错误)