Recieve data from database with ID and without JSON

69 Views Asked by At

I am trying to get data from database but without JSON. But when i tried this code, i get error. Any ideas? I am doing this almost week and I really do not know. My head is almost hairless.

let request = NSMutableURLRequest(url: NSURL(string: "http://servis.dronysitmp.cz/cteni_baterie.php")! as URL)
    request.httpMethod = "GET"

    let getString = "a=\(oznaceni)"


    request.httpBody = getString.data(using: String.Encoding.utf8)

    let task = URLSession.shared.dataTask(with: request as URLRequest) {
        data, response, error in

        if error != nil {
            print("error=\(String(describing: error))")
            return
        }

        print("response = \(String(describing: response))")

        let responseString = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)
        print("responseString = \(String(describing: responseString))")
    }
    task.resume()
}

2017-09-11 10:50:31.406216+0200 cteni_pod_indexem[434:489371] [] nw_endpoint_flow_service_writes [6.1 87.236.196.140:80 ready socket-flow (satisfied)] Write request has 4294967295 frame count, 0 byte count

2017-09-11 10:50:41.488729+0200 cteni_pod_indexem[434:489371] [] nw_endpoint_handler_add_write_request [4.1 87.236.196.140:80 failed socket-flow (satisfied)] cannot accept write requests

2017-09-11 10:50:41.492515+0200 cteni_pod_indexem[434:489383] [] tcp_connection_write_eof_block_invoke Write close callback received error: [22] Invalid argument error=Optional(Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x17005a5b0 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=http://servis.dronysitmp.cz/cteni_baterie.php, NSErrorFailingURLKey=http://servis.dronysitmp.cz/cteni_baterie.php, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out.}

I have solve this, just changed the httpMethod to "POST"

0

There are 0 best solutions below