title: How to get JSON data with HTTP Post method in swift 3?
body: <p>I confuse by getting HTTP response in post method. when i check response on postman, then the required response is got and profile updated successfully. But in programmatically i got error notice. What was the problem? how to solve it? please, refer screenshots. Thanks in advance!</p>
  
  <p><strong>Code i have try</strong> </p>
  
  <pre><code>override func viewDidLoad() {
          super.viewDidLoad()
          self.updateDetails()
  
      }
  
  
      func updateDetails()
      {
  
          let postString = "api=update_people&amp;user_id=18&amp;email=rajesh@gmail.com&amp;first_name=Raejsh&amp;phone=456562&amp;age=26&amp;gender=male&amp;blood_group=A"
  
          print(postString)
  
          //  let alertMessage = alert()
  
          let url = NSURL(string: "http://kuruthi.in/portal/api/register")
  
          let request = NSMutableURLRequest(url: url as! URL)
  
          request.httpBody = postString.data(using: String.Encoding.utf8)
          request.httpMethod = "POST"
          request.addValue("123456", forHTTPHeaderField: "X-API-KEY")
          request.addValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
  
  
          let task = URLSession.shared.dataTask(with: request as URLRequest) { data,response,error in
              guard error == nil &amp;&amp; data != nil else
              {
  
                  print("Error:\(error)")
                  return
              }
  
              let httpStatus = response as? HTTPURLResponse
  
              if httpStatus!.statusCode == 200
              {
                  if data?.count != 0
                  {
                      let responseString = String(data: data!, encoding: .utf8)
                      print(responseString)
  
                  }
                  else
                  {
                      print("No data got from url!")
  
                  }
              }
              else
              {
  
                  print("error httpstatus code")
              }
          }
          task.resume()
  
      }
  </code></pre>
  
  <p><strong>Response in Program output :</strong>
  <a href="https://i.stack.imgur.com/Ejcj9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ejcj9.png" alt="enter image description here"></a></p>
  
  <p><strong>Response in postman:</strong>
  <a href="https://i.stack.imgur.com/iajId.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iajId.png" alt="enter image description here"></a></p>