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. trying to get response from web service and encountering error 301

trying to get response from web service and encountering error 301

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 935 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.
  • E Offline
    E Offline
    eh_sun
    wrote on last edited by eh_sun
    #1

    i send this post request with parameters: device_ID=1&pin_code=11111111 expecting to get xml response "true". but i get error code 301 every time. i have not any idea what the problem is
    Can anyone help me?
    thanks

    web service address: http://danaab.org/service/client_srv.asmx?op=Check_Pin_Code

    QByteArray post = QByteArray("device_ID=1&pin_code=11111111");
    
        QNetworkRequest req = QNetworkRequest(QUrl("danaab.org/service/client_srv.asmx/Check_Pin_Code"));
        req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
        connect(network_access_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(serviceRequestFinished(QNetworkReply*)));
        network_access_manager->post(req, post);
    
    void MainWindow::serviceRequestFinished(QNetworkReply *reply)
    {
        reply->deleteLater();
        if(reply->error() == QNetworkReply::NoError)
        {
            receivedData = reply->readAll();
            QString myString(receivedData);
            msg->setText("Response: " + myString);
            msg->exec();
        }
        else
        {
            msg->setText("Error: " + QString::number(int(reply->error())));
            msg->exec();
        }
    }
    
    1 Reply Last reply
    0
    • B Offline
      B Offline
      bludger
      wrote on last edited by
      #2

      I had a quick look. Is there any reason you don't inlcude the scheme (http://) in the url?

      1 Reply Last reply
      2
      • E Offline
        E Offline
        eh_sun
        wrote on last edited by
        #3

        it worked!
        i thought that is an optional phrase! because it worked in browser without "http://" too
        thank you

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi and welcome to devnet,

          That's because web browsers default to http if you don't specify anything.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1

          • Login

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