title: Perform POST request in iOS Swift
body: <p>I am trying perform a POST request and the request does not go through. I have looked through <a href="https://stackoverflow.com/questions/24068866/perform-post-request-in-swift">Perform POST request in Swift</a> already but it does not contain what I'm looking for.</p>
  
  <pre><code>func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -&gt; Bool {
      var request = NSMutableURLRequest(URL: NSURL(string: "https://us1.lacunaexpanse.com"))
      println("request url https://us1.lacunaexpanse.com")
      var session = NSURLSession.sharedSession()
      request.HTTPMethod = "POST"
  
      let apikey = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
      println("apikey",apikey)
  
      let username = "username"
      let password = "password"
  
      var login = Array(["username", "password", "apikey"])
  
      let jsonDictionary = ["2.0", "jsonrpc", "1", "id", "login", "method", "login", "params"]
      println("jsonDictionary",jsonDictionary)
  
      var writeError: NSError?
  
      let jsonData = NSJSONSerialization.dataWithJSONObject(jsonDictionary, options: NSJSONWritingOptions(), error: NSErrorPointer())
  
      var resultAsString = NSString(data: jsonData, encoding: NSUTF8StringEncoding)
  
      resultAsString = resultAsString.stringByAppendingString("empire")
  
      let url = NSURL.URLWithString("string")
      println("url",url)
  
      var request2 = NSMutableURLRequest()
      println("Post url =%@",url)
  
      request2 = NSMutableURLRequest(URL:url)
  
      request2.HTTPMethod = "POST"
  
      var connection = NSURLConnection(request: request, delegate: self, startImmediately: false)
  
      return true
  </code></pre>