views:

233

answers:

2

I have a webservice that I need to POST some data to using Qt. I figured that I can use a QByteArray when POSTing to the web service.

My question is, how can I format this array in order to be parsed correctly at the other end?

This is the code I have so far:

    // Setup the webservice url
    QUrl serviceUrl = QUrl("http://myserver/myservice.asmx");
    QByteArray postData;

   /* 
   Setup the post data somehow
   I want to transmit:
   param1=string,
   param2=string
   */

    // Call the webservice
    QNetworkAccessManager *networkManager = new QNetworkAccessManager(this);
    connect(networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(serviceRequestFinished(QNetworkReply*)));
    networkManager->post(QNetworkRequest(serviceUrl), postData);

Thanks!

+2  A: 
QByteArray postData;
postData.append("param1=string,\n");
postData.append("param2=string\n");
guruz
A: 

I used:

QByteArray postData;
postData.append("param1=string&");
postData.append("param2=string");

So & instead of newline after each parameter.

Juha Palomäki