Results 1 to 6 of 6

Thread: HTTP request POST in QT application

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2011
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: HTTP request POST in QT application

    This is what I am trying:

    DownloadManager:ownloadManager()
    {
    QNetworkAccessManager *manager = new QNetworkAccessManager(this);
    QUrl url("https://accounts.google.com/o/oauth2/token");
    QNetworkRequest request(url);
    request.setHeader(QNetworkRequest::ContentTypeHead er, "application/x-www-form-urlencoded");
    QUrl params;
    params.addQueryItem("client_id", "example.com");
    params.addQueryItem("client_secret", "example_secret");
    params.addQueryItem("code", "example_code");
    params.addQueryItem("redirect_uri", "urn:ietf:wgauth:2.0ob");
    params.addQueryItem("grant_type", "authorization_code");

    QObject::connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(replyfinished(QNetworkReply *)));

    QNetworkReply *reply=manager->post(request, params.encodedQuery());

    }


    void DownloadManager::replyfinished(QNetworkReply *reply)
    {
    int i;
    QByteArray bytes = reply->readAll(); // bytes
    qDebug("reply received");

    for(i=0;i<=bytes.size();i++)
    qDebug() << bytes.at(i);

    }


    I am not getting any response from server since reply->readAll(); is not returning anything.

    Can you help me out.

    If else can u please tell me how to use KQOauth/QOauth to access google contacts api.

    Thanks in advance

    Regards
    Abdul Moiz

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: HTTP request POST in QT application

    See your other thread... the answer is probably the same. Also, a finished transfer is not necessarily a successful transfer. Have you looked at QNetworkReply::error()?
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

Similar Threads

  1. Request ID of QNetworkaccessmanager get and post request
    By dineshkumar in forum Qt Programming
    Replies: 2
    Last Post: 4th February 2011, 22:56
  2. HTTP request
    By Trok in forum Qt Programming
    Replies: 9
    Last Post: 5th January 2010, 15:49
  3. How do I send data with http post request?
    By Morea in forum Qt Programming
    Replies: 13
    Last Post: 21st January 2009, 23:51
  4. http request
    By yagabey in forum Qt Programming
    Replies: 3
    Last Post: 28th December 2008, 20:19
  5. POST request to a web service
    By QPlace in forum Qt Programming
    Replies: 3
    Last Post: 6th November 2008, 09:05

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
  •  
Qt is a trademark of The Qt Company.