Response.result.value in method post alalofire noil
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)
}
I am working in post api method and above code doesn't work. I am getting a null response. But this url works correctly in postman studio and android. What is the cause of this problem?
+3
source to share
2 answers
Your url only works when requested using url encoded form
Try using this as documented on GitHub
Alamofire.request("http://nanosoftech.com/store/user_check", method: .post, parameters: parametersDictionary , encoding: URLEncoding.default)
If this encoding doesn't work try encoding: URLEncoding.httpBody
+1
source to share
Just write, see below. It works for me
Alamofire.request("http://era.com.bd/UserSignInSV", method: .post,parameters:["uname":txtUserId.text!,"pass":txtPassword.text!]).responseJSON{(responseData) -> Void in
if((responseData.result.value != nil)){
let jsonData = JSON(responseData.result.value)
}
}
0
source to share