I'm trying make a request with Alamofire but the errors occurs in parameterer method: HTTPMethod
, I used the suggestive parameter .post
.
Alamofire.request(OdooAuth.host2!, method: .post, parameters: [String:Any], encoding: JSONEncoding.default, headers: [])
The host is ok because if I try the other way like:
AlamofireXMLRPC.request(OdooAuth.host2!, methodName: "execute_kw", parameters: params)
This works.
The problem is that I want use JSON instead XML.
Error in XCode:
I've searched in many posts on the web, Github, Stackoverflow, but the problems similars not have answer or not solves my problem.
Try This
let _headers = ["Content-Type": "application/json"]
Alamofire.request(url as URL, method: .post, parameters: params, encoding: JSONEncoding.default, headers: _headers).responseJSON { response in
do {
let jsonData = try JSONSerialization.jsonObject(with: response.data!, options: .mutableContainers) as? JSONStandard
if (jsonData != nil) {
let jsonData = response as! Dictionary // PARSE AS PER RESPONSE
} else {
print("No Data")
}
} catch {
print("Error")
}
}