title: alamofire.error Code=-6006 "JSON could not be serialized
body: <p>Been working on this for a bit with no success. I have a function that goes to a <code>UIButton</code> solely to perform alamofire calls to my rails api which uses all JSON. </p>
  
  <p>I'm using Swift 2, Alamofire 3, XCode 7 &amp; Rails 4 for my api which is deployed to Heroku</p>
  
  <p>I keep getting this error when I fire off the function :</p>
  
  <blockquote>
    <p>alamofire.error Code=-6006 "JSON could not be serialized. Input data was nil or zero length.</p>
  </blockquote>
  
  <p>Here is my code :</p>
  
  <pre><code>@IBAction func Save(sender: AnyObject) {
  
      let postsEndpoint: String = "https://APIURL"
      let parameters = [
          "users": [
              "name": "James McHarty",
              "avatar": "Some binary data",
              "post": [
                  "title": "First Test Post",
                  "body": "This is the first test post for the API",
                  "liked": "8", //will make INT later
                  "img": "more binary data"
              ]
          ]
      ]
  
      Alamofire.request(.POST, postsEndpoint, parameters: parameters, encoding: .JSON)
          .responseJSON { response in
              guard response.result.error == nil else {
              // got an error in getting the data, need to handle it
              print(response.result.error!)
              return
          }
  
      }
  
      print("func'd")
  
  }
  </code></pre>