title: How to do multipart/form-data post request with Swift?
body: <pre><code> let Url = String(format: "http://url/ios.php")
      guard let serviceUrl = URL(string: Url) else { return }
      let parameterDictionary :[String:String] = ["Episodes" : "http://url/anime/07-ghost.html"]
      var request = URLRequest(url: serviceUrl)
      request.httpMethod = "POST"
      request.setValue("multipart/form-data", forHTTPHeaderField: "Content-Type")
      request.httpBody = NSKeyedArchiver.archivedData(withRootObject: parameterDictionary)
      let session = URLSession.shared
      session.dataTask(with: request) { (data, response, error) in
          if let response = response {
              print(response)
          }
          if let data = data {
              do {
                  let json = try JSONSerialization.jsonObject(with: data, options: [])
                  print(json)
              }catch {
                  print(error)
              }
          }
          }.resume()
      }
  </code></pre>
  
  <p>I get error </p>
  
  <pre><code>Error Domain=NSCocoaErrorDomain Code=3840 "No value." UserInfo={NSDebugDescription=No value.}
  </code></pre>
  
  <p>not sure if im sending data correctly, i think im setting httpbody incorectly </p>
  
  <p>i even tried with json
      request.setValue("application/json", forHTTPHeaderField: "Content-Type")
          guard let httpBody = try? JSONSerialization.data(withJSONObject: parameterDictionary, options: []) else {
              return
          }</p>