Sending JSON POST request in Swift3
<p>In my app i'm trying to make http post request with json data. The following json must be transferred to api</p>

<pre><code>{ 
 "Password":"123456",   
 "Email":"test@gmail.com"
}
</code></pre>

<p>Here is my code for this task</p>

<pre><code>let dict = ["Email": "test@gmail.com", "Password":"123456"] as [String: Any]
if let jsonData = try? JSONSerialization.data(withJSONObject: dict, options: []) {


    let url = NSURL(string: "http://xxxxxxxxx.net/api/Login")!
    let request = NSMutableURLRequest(url: url as URL)
    request.httpMethod = "POST"

    request.httpBody = jsonData

    let task = URLSession.shared.dataTask(with: request as URLRequest){ data,response,error in
        if error != nil{
           print(error?.localizedDescription)
           return
        }

        do {
            let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary

            if let parseJSON = json {
                   let resultValue:String = parseJSON["success"] as! String;
                   print("result: \(resultValue)")
                   print(parseJSON)
                   }
            } catch let error as NSError {
                 print(error)
            }        
       }          
     task.resume()
    }
</code></pre>

<p>I'm getting the following error</p>

<pre><code>Error Domain=NSCocoaErrorDomain Code=3840 "No value." UserInfo={NSDebugDescription=No value.}
</code></pre>

<p>The response data is empty. What I'm doing wrong, or i have missed something in my code?</p>