I'm trying to parse a JSON from a post request but I need to pass the content as x-www-form-urlencoded. I'm using Alamofire and Swift5, the code used to perform the request is this:
public func performRequest(url: String, parameters: [String:String]){
AF.request(url, method: .post, parameters: parameters, encoding: URLEncoding.httpBody).validate().responseJSON{ response in
switch response.result {
case .success(let JSON): // memorizza il file JSON di risposta in una variabile di nome JSON
print("Validation Successful with response JSON \(JSON)")
case .failure(let error):
// print(error.localizedDescription)
print("Request failed with error \(error)")
}
}
}
How do I pass the content as x-www-form-urlencoded?