I have POST request that takes body as parameters.
I tried this, but I didn't get any Response, Does Alamofire allow to Send body parameters when making API Requests?
let params = [
"course":"1",
"batch":"1"
]
Alamofire.request(markURL, method: .post, parameters: params, encoding: JSONEncoding.default, headers: headers).responseJSON { (response) in
if((response.result.value) != nil) {
var jsonVar = JSON(response.result.value!)
print(jsonVar)
}
}
I'm Kinda stuck, Any help would be appreciated.
Change your encoding like this:
Alamofire.request(markURL, method: .post, parameters: params, encoding: URLEncoding.httpBody, headers: headers).responseJSON { (response) in
if((response.result.value) != nil) {
var jsonVar = JSON(response.result.value!)
print(jsonVar)
}
}