The problem is that you are using URLEncoding.default . Alamofire interprets URLEncoding.default differently depending on the HTTP method .
For GET , HEAD and DELETE requests, URLEncoding.default encodes the parameters as a query string and adds them to the URL, but for any other method (for example, POST ), the parameters are encoded as a query string and sent as the body of an HTTP request.
To use the query string in a POST request, you need to change your encoding argument to URLEncoding(destination: .queryString) .
You can see more details on how Alamofire handles request parameters here .
Your code should look like this:
_url = "http://localhost:8080/" let parameters: Parameters = [ "test": "123" ] Alamofire.request(_url, method: .post, parameters: parameters, encoding: URLEncoding(destination: .queryString), headers: headers)
Pedro castilho
source share