I'm working on Alamofire and I am trying to post a request to the server like this:
func sendRequest () {
print("fire now----------------------------------------------")
let parameters: Parameters = ["user": "001", "name": "josh"]
print(parameters)
let a = Alamofire.request("http://120.77.252.96:8388/", method: .get, parameters: parameters, encoding: URLEncoding.default).validate(statusCode: 200..<500).responseJSON(completionHandler: {responds in
switch responds.result {
case .success(let value):
let json = JSON(value)
print("JSON: \(json)")
case .failure(let error):
print(error)
}}
)
print(a)
}
But I constantly get errors like this:
Alamofire.AFError.ResponseValidationFailureReason.unacceptableStatusCode(500)
and when I check the server side, it seems that the body of the request is empty.
Can anyone help me with this? Thanks so much!