[Swift, Alamofire]: responseValidationFailed with error code 400
The erro log responseValidationFailed(Alamofire.AFError.ResponseValidationFailureReason.unacceptableStatusCode(400)) clearly shows that you are getting 400 error. Which is explained in W3.org as
400 Bad Request: The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.
So you need to chek you request URL if it is correct.
Also, you are using validate() method of request which is supposed to get response status codes 200...299, but you are getting 400 as response code. Thats why it is mentioned as unacceptableStatusCode(400) in error log.
Seel this also.
Admin
Updated on June 27, 2022Comments
-
Admin almost 2 years
My problem is basically in the title. The code that I am trying to run is just below. VVV
let unfollow = "https://api.instagram.com/v1/users/\(userID)/relationship?access_token=\(access_token)&action=unfollow" Alamofire.request(unfollow, method: .post).validate().responseJSON(completionHandler: { response in switch response.result { case .success(let value): let data = JSON(value)["data"] print(data["outgoing_status"].stringValue) case .failure(let error): print(error) } })
The exact console error I recieve is:
responseValidationFailed(Alamofire.AFError.ResponseValidationFailureReason.unacceptableStatusCode(400))
I am using the Instagram API by the way but I don't think that that is necessarily related to the issue.
Any help greatly appreciated.