Hi, I want to send my JSON string directly to Server body. But here now im coverting my json string to dictionary and that dictiaonry passing to parameters.
So is there any alternative to send plain json object.
Had the same thing today and I searched backwards in closed tickets and found this.
https://github.com/Alamofire/Alamofire/issues/1103
Passing in JSON works in his initial comment if you also add the following to it
mutableRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
Hi @srinadh588,
There's an example of posting JSON to a server in our README which can be found here.
let parameters = [
"foo": [1,2,3],
"bar": [
"baz": "qux"
]
]
Alamofire.request(.POST, "https://httpbin.org/post", parameters: parameters, encoding: .JSON)
// HTTP body: {"foo": [1, 2, 3], "bar": {"baz": "qux"}}
In the future, I'd recommend opening a question on Stack Overflow for questions like this. We use our GitHub project for bug reports and feature requests.
Best of luck! 馃嵒
From our Contribution Guidelines
We don't use GitHub as a support forum. For any usage questions that are not specific to the project itself, please ask on Stack Overflow instead. By doing so, you'll be more likely to quickly solve your problem, and you'll allow anyone else with the same question to find the answer. This also allows maintainers to focus on improving the project for others.
Sure, i will request in stack overflow. but in Swift we care objctes file look like follwoing.
Class Obj : NSObject {
var name : String?
var emial : String?
}
So, how can we send like this object to server. i tried to convery above object to jsonstirng and then i need to convery jsonstring to dictionary like above you mentions. but too many steps to do.
did you found any solution, for me I'm using struct, but the same problem on alamofire.upload
i have same problem, i want to send json or object instead of parameter but i cant! i even open issue in astackoverflow but didnt get the answer till now! https://stackoverflow.com/questions/54268571/is-there-any-way-to-send-data-as-object-instead-of-parameter-in-alamofire
@cnoon the solution you said doesn't work