Hello, I am trying to send a Json request using QNetworkAccessManager:: post.
All examples I found recommend to create a Json object and to pass it as the 2nd argument of the post call.
This must be an older API though because according to the Qt5 docs QNetworkAccessManager:: post takes as 2nd argument a destination for the data received.
This leaves me with the problem of sending my Json request somehow.

To better illustrate my predicament, this is the curl version of my request:

curl
-H "Content-Type:application/json"
-d '{"generalSearchInput":"..", "requireAllWords":"true","pageNumber":"1"}'
https://<url>/search?api_key=######


If I didn't need to send the api key it appears the following would work:

QUrl target_url("https://<url>/search");
target_url.setScheme("https");
target_url.setQuery("{\ "generalSearchInput\ ":\ "..\ ", \ "requireAllWords\ ":\ "true\ ",\ "pageNumber\ ":\ "1\ "}");
QNetworkRequest request(target_url);
request.setRawHeader("Content-Type", "application/json");
QByteArray data;
netReply = netManager->post(request, data);


but of course it complains it needs the api key.

To give the api key I would need a QUrlQuery, so I can do:

QUrlQuery query;
query.addQueryItem("api_key", "#####");
target_url.setQuery(query);


but now I can't send my json string anymore.

How do I get myself out of all this?