Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alamofire always give me error with status code 500 in response

I'm facing the following problem, I'm trying to use Alamofire to access to a few Web services in my application, this is the code that i'm using:

Alamofire.request(.GET, "https://httpbin.org/get")
        .validate()
        .responseJSON { response in
            switch response.result {
            case .Success:
                print("Validation Successful")
            case .Failure(let error):
                print(error)
            }
    }

the result for this is "Validation Successful" and this is right, but the problem is when i'm trying to call my own service this is the url of the web service if anyone want to check it out: https://ratid.com/RapidSentry/MiOSService.svc/GetUserIdentity... This web service is working fine as you could see, but when i'm calling the same code but with my url i got the following error:

Error Domain=com.alamofire.error Code=-6003 "Response status code was unacceptable: 500" UserInfo={NSLocalizedFailureReason=Response status code was unacceptable: 500}

I'm using already this web service in an android application and work fine with the GET request Please i'll appreciate any help with this issue. Note: I'm using Xcode 7 and swift.

like image 741
Jose Raul Perera Avatar asked Oct 09 '15 18:10

Jose Raul Perera


1 Answers

Pass the acceptable range of status codes in to the validate function like this :

.validate(statusCode: 200..<500)
like image 81
UglyBlueCat Avatar answered Oct 14 '22 08:10

UglyBlueCat