title: Swift + ios 9, sending post data with base64 image data
body: <p>I have looked at the different questions related to send a post request with NS on swift. I am having issues however with the following code where the responding server doesn't even see it as being a post request.</p>
  
  <p>What am I missing:</p>
  
  <pre><code>    var request = NSMutableURLRequest(URL: NSURL(string: url)!)
  
  
      request.HTTPMethod = "POST"
  
      request.addValue("application/json", forHTTPHeaderField: "Content-Type")
  
      request.addValue("application/json", forHTTPHeaderField: "Accept")
  
  
  
      var imageData = UIImageJPEGRepresentation(img, 0.6)
  
      var base64String = imageData.base64EncodedStringWithOptions(NSDataBase64EncodingOptions(rawValue: 0)) // encode the image
  
  
  
      var err: NSError? = nil
  
      var params = ["image":[ "content_type": "image/jpeg", "filename":"\(self.riderid).jpg", "file_data": base64String]]
  
      println("Image params \(params)")
  
      request.HTTPBody = NSJSONSerialization.dataWithJSONObject(params, options: NSJSONWritingOptions(0), error: &amp;err)!
  
  
  
  
      var task = session.dataTaskWithRequest(request, completionHandler: { data, response, error -&gt; Void in
  
          var strData = NSString(data: data, encoding: NSUTF8StringEncoding)
  
          var err: NSError?
  
          println("Image Response \(err) \(data)")
  
          // process the response
  
          var hoge = JSON(data: data!)
  
          println("Image Response \(hoge)")
  
  
  
      })
  </code></pre>