Closed stami closed 8 years ago
@stami Thanks a lot for your question. This is not supported at the moment, solely because we didn't have the need for it internally. I recognise it is a super common scenario for many apis so we need so support this asap. If you're in a hurry I'd say do it with pure Alamofire, but we are going to integrate this shortly (~1 week). Thanks for helping us improve ws :)
@stami we landed a first implementation on branch "multipart". You can now configure post parameter encoding like so :
ws.postParameterEncoding = .JSON
Default is .URL
If you could try it out that'd be awesome \o/
Nice, thanks! I'll try it out and let you know about any issues I encounter.
So far, so good. I had other issues too in my first comment (that HTTP 400 was about wrong url and that log print wasn't the actual json string that was sent). I got the url right and then it was just about parameter encoding.
I'm sending objects like below and everything is working. 😊 (https://github.com/stami/Location/blob/master/Location/Exercise.swift)
{
"startingDate": "2016-04-25T15:29:03+0300",
"averageSpeed": 33.27111135904285,
"totalDistance": 66.65936915586187,
"description": "Nice running",
"trace": [
{
"latitude": 37.47004943,
"longitude": -122.29347317,
"timestamp": "2016-04-25T15:29:03+0300"
},
...
]
}
I needed JSON parameter encoding also with PUT method and made a pull request about it. If you merge the request (or do something better) I consider this issue closed. 😊
@stami version 1.2 just got released and it packs the additions we made on multipart :) Thanks a ton for your help on this feature 👍
How can I serialize POST params as JSON?
Let's say we have save() like this
Log output is
So params should be something like
Can this be accomplished easily with ws, or should I be looking for alternatives or plain Alamofire?