Reposting as I messed up with the type of encoding before... I need to send an array to the server with Alamofire using URLEncoding. However, it needs to be encoded in some way for Alamofire to send it properly. This is my code:
let parameters: [String : Any] = [
"names" : ["bob", "fred"]
]
Alamofire.request(urlString, method: .post, parameters: parameters, encoding: URLEncoding.default)
.responseJSON { response in
// etc
}
However the parameters never get encoded and just get sent as nil. How can I encode it?
As of now you can use for this & issue on parameters:
let enc = URLEncoding(arrayEncoding: .noBrackets)
Alamofire.request(url, method: .get, parameters: parameters, encoding: enc)
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