Unsolved QUrl supports Post?
-
Hi together,
i am using C++ to send some data to the server but got a problem now.
QUrlQuery is sending the data in the url like "www.bla.bla&id=1&etc" with the GET Method.But i need to send the data with the POST Method because im sending more than 20k chars.
Right now it looks like this
QUrlQuery query;
query.addQueryItem(QStringLiteral("data1"), data1);
query.addQueryItem(QStringLiteral("data2"), data2);QUrl requestUrl(m_url);
requestUrl.setQuery(query);
QNetworkRequest request(requestUrl);
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
request.setPriority(QNetworkRequest::HighPriority);
QNetworkReply *reply = manager->get(request);
connect(reply, &QNetworkReply::finished, this, [this, reply] {
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> replyPtr(reply);
m_data = replyPtr->readAll();
qDebug() << m_data;
});So the problem is, Get is limited and i get an error from the server.
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n<html><head>\n<title>414 Request-URI Too Long</title>\n</head><body>\n<h1>Request-URI Too Long</h1>\n<p>The requested URL's length exceeds the capacity\nlimit for this server.<br />\n</p>\n<hr>\n<address>Apache Server at default Port 80</address>\n</body></html>
How can i use the Post Method?
thx 4 help
-
Hi,
@Dev1337 said:
How can i use the Post Method?
Call
QNetworkAccessManager::post()
instead ofQNetworkAccessManager::get()
. -
Thx worked.