Reputation: 878
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.
Upvotes: 10
Views: 13645
Reputation: 878
I want to give a feedback about this, it seems to be a bug in the simulator for Xcode 7 Beta because I tested the application on a physical device and it worked fine. Also when you reset the simulator and rebooting then it start working again. This is the problem that we faced using betas`.
Upvotes: 6
Reputation: 477
Pass the acceptable range of status codes in to the validate function like this :
.validate(statusCode: 200..<500)
Upvotes: 2
Reputation: 3023
You can change range of acceptableStatusCodes in Alamofire/validation.swift file from 200..<300 to 200..<500
replace below line
let acceptableStatusCodes: Range<Int> = 200..<300
with this line
let acceptableStatusCodes: Range<Int> = 200..<500
Upvotes: 4
Reputation: 2586
Status code 500 means that there is a problem with the server, not with your code.
Upvotes: 3