how is it possible to send a POST request with a simple string in the HTTP body with Alamofire in my iOS app?
As default Alamofire needs parameters for a request:
Alamofire.request(.POST, "http://mywebsite.com/post-request", parameters: ["foo": "bar"])
These parameters contain key-value-pairs. But I don't want to send a request with a key-value string in the HTTP body.
I mean something like this:
Alamofire.request(.POST, "http://mywebsite.com/post-request", body: "myBodyString")
If you want to post string as raw body in request
I have done it for array from strings. This solution is adjusted for string in body.
The "native" way from Alamofire 4:
And then make your request with:
I modified @Silmaril's answer to extend Alamofire's Manager. This solution uses EVReflection to serialize an object directly:
Then you can use it like this: