trying to get response from web service and encountering error 301



  • 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();
        }
    }
    


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



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


  • Lifetime Qt Champion

    Hi and welcome to devnet,

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.