PDA

View Full Version : Sending Json post request in 5.6



d1psy
24th August 2016, 14:52
This code worked perfectly fine in Qt 5.5, but after porting to 5.6 (from webKit to webEngine), this code doesn't send anything anymore for some reason

QString jsonString = "Some string info";uploadManager = new QNetworkAccessManager(this);
QNetworkRequest rqData (theApp->getDomain() + "PageOnServerName.php");
rqData.setHeader(QNetworkRequest::ContentTypeHeade r, "application/x-www-form-urlencoded");
QNetworkReply * r = uploadManager->post(rqData, jsonString.toLatin1());
QEventLoop loop;
QTimer::singleShot(std::max(10u,timeout_msecs),&loop,SLOT(quit()));
r->connect(r, SIGNAL(finished()), &loop, SLOT(quit()));
r->connect(r, SIGNAL(error(QNetworkReply::NetworkError)), &loop, SLOT(quit())); loop.exec();

anda_skoa
24th August 2016, 15:25
Have you checked for errors?

Cheers,
_

d1psy
24th August 2016, 18:03
how? qDebug() << r->readAll(); gives me "Invalid session" and qDebug() << r->errorString(); gives me "Unknown error"

anda_skoa
24th August 2016, 19:34
Yes, by looking at errorString(), error(), the HTTP response code, etc.

Cheers,
_

d1psy
24th August 2016, 19:59
Well, I've just said, that errorString gives me "Unknown error". But it also gave me the same in previous version. But readAll() gives me "Invalid session", while in previous version it gave nothing