title: How to send base64 strings to POST service - Swift
body: <p>I have a problem sending a base64 imagen string to post service in swift 4. This service received "string json post"  and  parameters in base64.</p>
  
  <p>this example:</p>
  
  <pre><code>{
    "dato1":"prueba@mail.com",
    "dato2":1,
    "video":{
      "NomVideo":"video.mp4",
      "TipVideo":"mp4",
      "ArchVideo":"Base64"
    },
    "listaImagen":[{
      "NomImagen":"imagen1.jpg",
      "TipImagen":"jpg",
      "ArchImagen":"JKANSDJKASNDASKDNSAJKDNASJKNSA"
    },
    {
      "OrdImagen":2,
      "NomImagen":"imagen2.jpg",
      "TipImagen":"jpg",
      "ArchImagen":"base64"
    }],
    "ObjetoPrincipal":{
      "objetoDato1":"akmdklamd",
      "objetoDato2":"lakmsksamk"
    }
  }
  </code></pre>
  
  <p>But when I send parameters in base64, the service doesn't return the answer,  and if do not send parameters in base64 the service responds correctly.</p>
  
  <p>My postservice</p>
  
  <pre><code>    class func postJsonWithHeaderAuthorization(_ url :NSString, data :NSString, authorizationParam: String, closure: @escaping (Data?, URLResponse?, Error?) -&gt; ()){
  
      let url = URL(string: url as String)
  
      let request = NSMutableURLRequest(url: url! )
  
      request.httpMethod = POST
      request.setValue("application/json", forHTTPHeaderField: "Content-Type")
      request.setValue("application/json", forHTTPHeaderField: "Accept")
      request.setValue(authorizationParam, forHTTPHeaderField: "authorization")
  
  
      let data = data.data(using: String.Encoding.utf8.rawValue)
  
  
      let task = URLSession.shared.uploadTask(with: request as URLRequest,from: data, completionHandler: { (data,response, error ) in
  
          closure(data ,response, error)
          return
      })
  
      task.resume()
  }
  </code></pre>
  
  <p>plist configuration:</p>
  
  <p>App transport Security Settings 
      Allow Arbitrary Loads   -   YES</p>
  
  <p>The base64 params is:
  k+62cf7vQn8T8o/+tVqAnlz1NIC3JJ2qEHJpjNmlU0wJ1NaVme1ZSmtKyPNADtSP7s17Z4eGNB0wf9OsP/ota8 ........(etc etc)</p>