Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED]Gett api with QtNetwork
ashwinrajeev last edited by
@ QByteArray data;
data = params.encodedQuery();
QNetworkAccessManager *manager = new QNetworkAccessManager();
QNetworkReply *reply = manager->post(request, data);
I am trying to login gett using the above code but reply->readAll is always returning ''
Here is the link of "Gett API Docs":https://open.ge.tt/1/doc/rest
deimos last edited by
the post() function is asynchronous, so when you reach the readAll() function nothing is read yet.
You shoud connect at least "finished()":http://qt-project.org/doc/qt-4.8/qnetworkaccessmanager.html#finished signal to your own defined slot function and there managed read bytes. See the "detailed description":http://qt-project.org/doc/qt-4.8/qnetworkaccessmanager.html#details.
Another thing about "post()":http://qt-project.org/doc/qt-4.8/qnetworkaccessmanager.html#post function:
bq. data must be open for reading and must remain valid until the finished() signal is emitted for this reply.
as stated in the doc, your QByteArray data; should be valid till the request is finished, so define it globally in your class.