ios - alamofire post 方法中的 response.result.value 为 nil

标签 ios json swift alamofire

        let parametersDictionary = [
        "email" : "name@gmail.com",
        "password" : "password"
    ]
    Alamofire.request("http://nanosoftech.com/store/user_check", method: .post, parameters: (parametersDictionary as NSDictionary) as? Parameters , encoding: JSONEncoding.default, headers: nil).responseJSON { response in
        print("response:", response.result.value)
    }

我在 post 方法 api 中工作,上面的代码不起作用。我没有得到任何回应。但是这个 url 在 postman 和 android studio 中也能正常工作。这个问题背后的原因是什么?

最佳答案

您的 url 仅在请求使用 url 编码的表单时有效

enter image description here

尝试使用它,作为 documented在 GitHub 上

Alamofire.request("http://nanosoftech.com/store/user_check", method: .post, parameters: parametersDictionary , encoding: URLEncoding.default)

如果此编码不起作用,请尝试编码:URLEncoding.httpBody

关于ios - alamofire post 方法中的 response.result.value 为 nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44954917/

相关文章:

c# - DataContractJsonSerializer 更改我的日期

java - 如何解析另一个 JSONArray 中的 JSONArray

arrays - 查找给定范围内的数字数组的所有生成值

json - Swift 4 没有正确解码 JSON 可选

ios - 使用 swift 在屏幕上拖动图像

ios - 我无法将值插入到 sqlite 数据库中

ios - 使用 aws lambda 是否可以使用基于时间的应用程序?

ios - 由于日期选择器位于 View Controller 的顶部栏中,因此如何使日期选择器出现在按钮单击时

ios - "Creating an image format with an unknown type is an error"与 UIImagePickerController

java - 为什么在序列化内置类型时会忽略 JsonAdapter 注解?