我一直在开发一个应用程序,我必须使用 alamofire 来发布。 但是,我不断收到错误,说
失败 错误:反馈提交失败。 可选(“操作无法完成。JSON无法序列化。输入数据为零或零长度。”)
我的代码如下
let reportJSON: [String : AnyObject] = [
"Name" : nameTextField.text!,
"Message" : reportTextView.text!
]
Alamofire.request(.POST, "API", parameters: reportJSON, encoding: .JSON).responseJSON{ response in
print(response.result)
guard response.result.error == nil else{
print("Error: feedback submission failed.")
print(response.result.error?.localizedDescription)
return
}
if let responseValue = response.result.value{
let recipeList = JSON(responseValue)
print(recipeList)
}
}
我对 .GET 没有任何问题,但我不知道如何使用 .POST。 如有任何帮助,我们将不胜感激。
最佳答案
看来您没有将正确的网址而不是“API”更改传递给帖子的有效网址。
关于json - swift :阿拉莫菲尔邮报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38447292/