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. Qt- Web service Requests
Qt 6.11 is out! See what's new in the release blog

Qt- Web service Requests

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 4.5k Views 1 Watching
  • 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I'm trying out web service requests using this site as an example:
    http://www.rcsb.org/pdb/software/rest.do

    I got some GET REST request to work, but I' have no idea how to send the XML POST for its advanced search service. This is what I tried:

    @
    void WindowWrapper::postRequest()
    {
    QNetworkRequest request;

    request.setRawHeader("Content-Type", "text/xml;charset=UTF-8");
    request.setUrl(QUrl(request_url_));
    
    QString query =
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
            "<orgPdbQuery>"
            "<queryType>org.pdb.query.simple.StructureIdQuery</queryType>"
            "<description>Simple query for a list of PDB IDs (1 IDs) : 3I5F</description>"
            "<structureIdList>3I5F</structureIdList>"
            "</orgPdbQuery>";
    
    QObject::connect(network_, SIGNAL(finished(QNetworkReply*)),
                     this, SLOT(slotRequestFinished(QNetworkReply*)));
    
    network_->post(request, query.toUtf8());
    

    }

    void WindowWrapper::slotRequestFinished(QNetworkReply* reply)
    {
    if(reply->error() > 0)
    {
    qDebug() << reply->errorString();
    }
    else
    {
    QByteArray data = reply->readAll();

        qDebug() << "Request successful!";
        qDebug() << data;             
    }
    

    }

    @

    And this is how i call the method:

    @
    wrapper_->set_request_url("http://www.rcsb.org/pdb/rest/search/");

    wrapper_->postRequest();
    @

    There's no error on the request, but i get no response at all...

    Does anyone know how can i do this?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      It seem that the service from that site only accepts application/x-www-form-urlencoded as Content-Type. Now it's working..

      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