Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]Gett api with QtNetwork

[SOLVED]Gett api with QtNetwork

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ashwinrajeev
    wrote on last edited by
    #1

    @ QByteArray data;
    QUrl params;
    params.addQueryItem("email", email);
    params.addQueryItem("password", password);
    params.addQueryItem("apikey", key);
    data = params.encodedQuery();
    QNetworkAccessManager *manager = new QNetworkAccessManager();
    QNetworkRequest request(QUrl("https://open.ge.tt/1/users/login"));
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/octet-stream");
    QNetworkReply *reply = manager->post(request, data);
    qDebug()<<reply->readAll();
    @
    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

    1 Reply Last reply
    0
    • D Offline
      D Offline
      deimos
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved