title: Swift - Multiple Parameters to webservice
body: <p>I have the following code that should send a username and password off to a webservice, in return I get a single integer back:</p>
  
  <pre><code> func attemptLogin() {
  
          let url:URL = URL(string: endpoint+"/LoginNew")!
          let session = URLSession.shared
  
          var request = URLRequest(url: url)
          request.httpMethod = "POST"
          request.cachePolicy = NSURLRequest.CachePolicy.reloadIgnoringCacheData
  
          let postString = "username="+txtUsername.text! + "; password="+txtPassword.text!
          request.httpBody = postString.data(using: String.Encoding.utf8)
  
          let task = session.dataTask(with: request as URLRequest) {
              (
              data, response, error) in
  
              guard let data = data, let _:URLResponse = response, error == nil else {
                  print("error")
                  return
              }
  
              let dataString =  String(data: data, encoding: String.Encoding.utf8)
              print(dataString)
  
          }
  
          task.resume()
  
      }
  </code></pre>
  
  <p>In my function I need to add two parameters are I'm trying to do in this line:</p>
  
  <pre><code> let postString = "username="+txtUsername.text! + "; password="+txtPassword.text!
          request.httpBody = postString.data(using: String.Encoding.utf8)
  </code></pre>
  
  <p>I am getting the following response from my web service when I run this however</p>
  
  <blockquote>
    <p>Optional("Missing parameter: password.\r\n")</p>
  </blockquote>
  
  <p>I am obviously not appending the parameters to the request properly but I'm not sure what I've done wrong.</p>