iOS URLRequest POST Failing Swift : <p>I am currently trying to make a POST request on the iOS platform with a JSON body. My request works in cURL, but I cannot get it to work in iOS; the request times out. Here is my swift code:</p>

<pre><code>    class func createNewChannel(name: String, priv: String, channelKey: String, handle: String, password: String, auth: String) {
    let baseURL = "http://10.0.0.220:3000/"

    let dict = ["name": name, "private": priv, "channelKey": channelKey, "handle": handle, "password": password,  "auth": auth] as [String : Any]
    let jsonData = JSON(dict)
    do {
        let post = try jsonData.rawData()
        let postLength = String(post.count)
        let url = URL(string: "\(baseURL)channel/createChannel")!
        var request = URLRequest(url: url)
        request.httpMethod = "POST"
        request.httpBody = post as Data
        request.setValue(postLength, forHTTPHeaderField: "Content-Length")
        request.setValue("application/json", forHTTPHeaderField: "Content-Type")
        request.setValue("application/json", forHTTPHeaderField: "Accept")

        let session = URLSession.shared
        let task = session.dataTask(with: request, completionHandler: { (data, response, error) in
            if error == nil {
                do {
                    let json = try JSON(data: data!)
                    print(json)
                }
                catch {
                    print(error.localizedDescription)
                }
            }
            else {
                print(error!)
            }
        })
       task.resume()
    }
    catch {
        print(error.localizedDescription)
    }
}
</code></pre>

<p>When I call this function, the request does not work...I am sure I am using the right url because it works with a GET endpoint. Am I missing any headers? Please let me know if you see something wrong with the request.</p>
