Answer the question
In order to leave comments, you need to log in
How to make a POST request in JSON format in QT?
What the request should look like:
{
"app": "*",
"time": "2014-11-07T16:21:02+03:00",
"requests": [
{
"func": "r_genres_list",
"id": "genres_list"
}
]
}
"requests": [
{
"func": "r_genres_list",
"id": "genres_list"
}
]
QUrl url ( "https://requestbin.net/r/bfeldb43" );
QByteArray reqdata;
reqdata.append( "&time=" + QDateTime::currentDateTime().toTimeSpec( Qt::OffsetFromUTC ).toString( Qt::ISODate ) );
reqdata.append( "&app=1" );
reqdata.append( "&requests= { \"func\": \"r_genres_list\", \"id\":\"genres_list\"}]" );
QNetworkRequest request( url );
request.setRawHeader( "jdata", "1" );
manager->post( request, reqdata );
Answer the question
In order to leave comments, you need to log in
To do this, you'd better create a QJsonObject or QVariantMap, fill it with data.
And then store them in QByteArray using QJsonDocument https://doc.qt.io/qt-5/qjsondocument.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question