When I upgraded to latest everything (Alamo 4, Swift 3 and XC 8) the following stopped posting parameters and I dont have a clue why...
let params = ["stripeToken": token.tokenId,
"name": name,
"email": email
]
Alamofire.request(requestString, method: .post, parameters: params, encoding: JSONEncoding.default)
.responseJSON { (response) in
if response.result.value is NSNull {
return
}
I had a similar issue, I changed encoding from JSONEncoding.default to URLEncoding.httpbody or encoding: URLEncoding.default
Alamofire.request(URL, method: .post, parameters: params, encoding: URLEncoding.httpBody).responseJSON { response in
if let data = response.data {
let json = String(data: data, encoding: String.Encoding.utf8)
print("Response: \(json)")
}
}
I have the same issue and finally fixed it. URLEncoding.httpBody didn't work for me... but URLEncoding.default did.
So I changed JSONEncoding.default to URLEncoding.default.
It's now passing the parameters to the backend.
Alamofire.request(loginURL, method: .post, parameters: params, encoding: URLEncoding.default, headers: nil)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With