It is my first time for me to use Alamofire
, and it got me really frustrated.
I'm using the following code to call a signup API on the backend API
Alamofire.request(.POST, "\(self.authBaseURL)/signup", parameters: params, headers: headers, encoding: .JSON)
.validate(statusCode: 200..<300)
.validate(contentType: ["application/json"])
.responseJSON { response in
switch response.result {
case .Success(let JSON):
print("Success with JSON: \(JSON)")
success(updatedUser)
case .Failure(let error):
print("Request failed with error: \(error)")
failure(error)
}
}
The problem is that the error object I'm getting in the .Failure
function doesn't contain the server side message.
I have tried to access the rest of the objects (request, response, data, result) I could not find my error message anywhere
I'm always getting the following error, no matter what the server message has to say. Request failed with error:
FAILURE: Error Domain=com.alamofire.error Code=-6003 "Response status code was unacceptable: 400" UserInfo={NSLocalizedFailureReason=Response status code was unacceptable: 400}
Is there is anything wrong I'm doing?
Swift 2.2, AlamoFire 3.3.0, Xcode 7.3