I am trying to execute this method that I did on android where with the help of retrofit with the @Body
clause I can send data in the service body, as it is appreciated I do not need to use key - value, I only use @Body
and the service works perfectly.
@POST("/Rest/Login") // <== post
Call<Car> getLogin(@Body Car car); //// **<=== @BODY**
but Now I try to do the same in swift using the JSONEncoding.default
but I don't know how to add my complete class to send in the service since the only way to send is with a key value in a Parameters
variable. Alamofire's documentation indicates the same by providing this example which does not work for me.
let parameters: Parameters = [
"foo": [1,2,3],
"bar": [
"baz": "qux"
]
]
Alamofire.request("https://httpbin.org/post", method: .post, parameters: parameters, encoding: JSONEncoding.default)
Because the service I run does not have a key-value, only the model is sent in the body and that's it. As the example I provide on android using @Body