req.setQuery("Key=XXXXXXXXXXXXX");
QNetworkRequest request(req);
request.setRawHeader("User-Agent", "Test");
request.setRawHeader("X-Custom-User-Agent", "Test");
request.setRawHeader("Content-Type", "application/json");
request.setRawHeader("Content-Length", postDataSize);
QNetworkAccessManager test;
connect(&test, SIGNAL(finished(QNetworkReply*)), &loop, SLOT(quit()));
QNetworkReply * reply = test.post(request, jsonString);
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onError(QNetworkReply::NetworkError)));
loop.exec();
qDebug() << response;
QByteArray jsonString = "{}";
QByteArray postDataSize = QByteArray::number(jsonString.size());
QUrl req("webpagehere");
req.setQuery("Key=XXXXXXXXXXXXX");
QNetworkRequest request(req);
request.setRawHeader("User-Agent", "Test");
request.setRawHeader("X-Custom-User-Agent", "Test");
request.setRawHeader("Content-Type", "application/json");
request.setRawHeader("Content-Length", postDataSize);
QNetworkAccessManager test;
QEventLoop loop;
connect(&test, SIGNAL(finished(QNetworkReply*)), &loop, SLOT(quit()));
QNetworkReply * reply = test.post(request, jsonString);
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onError(QNetworkReply::NetworkError)));
loop.exec();
QByteArray response = reply->readAll();
qDebug() << response;
To copy to clipboard, switch view to plain text mode
Bookmarks