Swift 5.1 & Alamofire 5.1 : GET method ERROR

1.4k Views Asked by At

when passing header and params: Alamofire.AFError.URLRequestValidationFailureReason.bodyDataInGETRequest(0 bytes)

 AF.request(urlString,method:.get, parameters: parameters, encoding: URLEncoding.httpBody, headers: headers).responseJSON { response in

              print(response)

 }
1

There are 1 best solutions below

0
On

As of Apple's 2019 OS versions, trying to make a GET request with body data will fail with an error. The value must be nil. Alamofire provides it's own error here in order to provide a consistent experience for Alamofire users, regardless of which OS their code is running on.