Results 1 to 5 of 5

Thread: Sending Json post request in 5.6

  1. #1
    Join Date
    Aug 2016
    Posts
    6
    Qt products
    Qt5
    Platforms
    Windows

    Default Sending Json post request in 5.6

    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
    Qt Code:
    1. QString jsonString = "Some string info";uploadManager = new QNetworkAccessManager(this);
    2. QNetworkRequest rqData (theApp->getDomain() + "PageOnServerName.php");
    3. rqData.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    4. QNetworkReply * r = uploadManager->post(rqData, jsonString.toLatin1());
    5. QEventLoop loop;
    6. QTimer::singleShot(std::max(10u,timeout_msecs),&loop,SLOT(quit()));
    7. r->connect(r, SIGNAL(finished()), &loop, SLOT(quit()));
    8. r->connect(r, SIGNAL(error(QNetworkReply::NetworkError)), &loop, SLOT(quit())); loop.exec();
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Sending Json post request in 5.6

    Have you checked for errors?

    Cheers,
    _

  3. #3
    Join Date
    Aug 2016
    Posts
    6
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Sending Json post request in 5.6

    how? qDebug() << r->readAll(); gives me "Invalid session" and qDebug() << r->errorString(); gives me "Unknown error"

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Sending Json post request in 5.6

    Yes, by looking at errorString(), error(), the HTTP response code, etc.

    Cheers,
    _

  5. #5
    Join Date
    Aug 2016
    Posts
    6
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Sending Json post request in 5.6

    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

Similar Threads

  1. Correct POST html with JSON data
    By Mbded in forum Qt Programming
    Replies: 11
    Last Post: 23rd August 2015, 10:19
  2. Sending HTTP POST network request
    By Ashley in forum Qt Programming
    Replies: 3
    Last Post: 1st April 2015, 21:41
  3. Send JSON & Key via HTTP POST
    By Poonarge in forum Newbie
    Replies: 3
    Last Post: 21st August 2014, 09:13
  4. ASP .NET - POST request method
    By Trok in forum Qt Programming
    Replies: 3
    Last Post: 6th October 2011, 22:52
  5. Request ID of QNetworkaccessmanager get and post request
    By dineshkumar in forum Qt Programming
    Replies: 2
    Last Post: 4th February 2011, 21:56

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.