title: Post method is not sending my data in api call
body: <p>Hi I'm new to swift and I made following api call o send data but it's not sending and I got following response.</p>
  
  <h2>Sent data</h2>
  
  <pre><code>firstName=gggg&amp;lastName=ggg&amp;username=fgg&amp;password=ghh&amp;email=ggg@gg.com&amp;latitude=25.0710693470323&amp;longitude=55.143004052641
  </code></pre>
  
  <h2>response</h2>
  
  <pre><code>responseString  {"status":"error","message":"Oops!!!Something went wrong..."}
  </code></pre>
  
  <p>But I can get all other validation messages such as "username cannot be empty".</p>
  
  <p>But I tried with Postman It also gives same error message as above on header methods but later I figured out and sent on Body Method and form of application/x-www-form-urlencoded then I got success response as below.</p>
  
  <p><a href="https://i.stack.imgur.com/zCVbh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zCVbh.png" alt="enter image description here"></a></p>
  
  <p>Following is the My API Call... Please somebody figure out what I am doing wrong or suggest me a better post api call.</p>
  
  <p>One more thing this is the same API call method I made it for "/homefeed" and got the response but we don't need to send any specific parameters for that. Please help me.</p>
  
  <pre><code> func addNewUser()
      {
          let url = URL(string: "https://xxxxxxxxxx.azurewebsites.net/api/addUser")!
  
          let firstName:String = firstnameTextFeild.text!
          let lastName:String = lastNameTxtField.text!
          let username:String = usernameTextField.text!
          let password:String = passwordTextField.text!
          let email:String = emailTextField.text!
          var request = URLRequest(url: url)
          request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
          request.httpMethod = "POST"
          let postString = "firstName=\(firstName)&amp;lastName=\(lastName)&amp;username=\(username)&amp;password=\(password)&amp;email=\(email)&amp;latitude=\(lat)&amp;longitude=\(long)"
          print("Sent Data -",postString)
          request.httpBody = postString.data(using: .utf8)
          /*
          do {
              request.httpBody = try JSONSerialization.data(withJSONObject: parameters, options: .prettyPrinted) // pass dictionary to nsdata object and set it as request body
  
          } catch let error {
              print(error.localizedDescription)
          }
         */
          let task = URLSession.shared.dataTask(with: request) { data, response, error in
              guard let data = data, error == nil else {                                                 // check for fundamental networking error
                  print("error=\(String(describing: error))")
                  return
              }
  
              if let httpStatus = response as? HTTPURLResponse, httpStatus.statusCode != 200 {           // check for http errors
                  print("statusCode should be 200, but is \(httpStatus.statusCode)")
                  print("response = \(String(describing: response))")
              }
  
              let responseString = String(data: data, encoding: .utf8)
  
              // print("responseString = \(String(describing: responseString))")
              print("responseString ", responseString ?? "resSt")
  
  
          }
          task.resume()
  
      }
  </code></pre>