Optional(Error Domain=com.alamofire.error Code=-6006 "JSON could not be serialized. Input data was nil or zero length." UserInfo={NSLocalizedFailureReason=JSON could not be serialized. Input data was nil or zero length.})
let parameters: [String: AnyObject] = [
"orderNo":orderId,
"cart": [
"name": cartItem.name,
"quantity": cartItem.quantity,
"amount": cartItem.amount,
"description": cartItem.description
"description": description
let headers = ["Content-Type": "application/json"]
Alamofire.request(.POST, UrlManager.someUrl, parameters: parameters, encoding: .JSON, headers: headers).responseJSON { response in
debugPrint(response)
So this req is not happening, i need in cart send array of unescaped json.
Also found http://stackoverflow.com/questions/37310679/alamofire-json-serialization-error-swift-2-0
Its possible sending array of dict as param?
Regards
Hi @martinkaplan,
The issue I think you're running into is that Alamofire cannot encode your parameters
as valid JSON. Most likely something is wrong with your parameters
dictionary. I don't see anything obvious in the sample code you posted. I also answered the Stack Overflow question you posted about the NSDate
encoding.
What I'd recommend you do is try to encode that parameters
object using NSJSONSerialization
directory to figure out why the decoding is failing. Once you have that figured out, it should just start working in Alamofire.
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
Asking Questions
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.