Hello

I have problem with send POST method to server with JSON data. Actualy I tryed many idea, also idea with this forum but nothing helped me. So finally I whant to will ask in this forum. Basicly I have html file which below content which working.

Qt Code:
  1. <html>
  2. <body>
  3. <form method="POST" action="http://192.168.1.108/ask.cgi">
  4. <input type="text" name="json"
  5. value='{"ctrl":{"c":"gd","i":2}}' size="100">
  6. <input type="submit">
  7. </form>
  8. </body>
  9. </html>
To copy to clipboard, switch view to plain text mode 

After I writed this text to let say test.html and execute, my serwer answer me correct, also in JSON data. So please me tell how to build POST method using Qt, and concret using QNetworkManager. I writed below code, but nothing happend. I see in wireshark how program traying something send but I do not get nothing.

Qt Code:
  1. QByteArray jsonString = "{\"trl\":{\"c\":\"gd\",\"i\":256}}";
  2. QByteArray postDataSize = QByteArray::number(jsonString.size());
  3.  
  4. QUrl serviceURL("http://192.168.1.108/ask.cgi/");
  5. QNetworkRequest request(serviceURL);
  6. request.setRawHeader("Content-Type", "application/x-www-form-urlencoded");
  7. request.setRawHeader("Content-Length", postDataSize);
  8.  
  9. QNetworkAccessManager test;
  10. QEventLoop loop;
  11. connect(&test, SIGNAL(finished(QNetworkReply*)), &loop, SLOT(quit()));
  12. QNetworkReply * reply = test.post(request, jsonString);
  13. loop.exec();
  14.  
  15. QByteArray response = reply->readAll();
  16. qd " slot" << response;
To copy to clipboard, switch view to plain text mode