qt - QNetworkAccessManager PUT request example needed -


i have been using qnetworkaccessmanager , post requests.

but need use put request update , external api. put requests needs json string part body sent update record.

i not find working example of put request using qnetworkaccessmanager.

please share sample code.

finally found way send json data in qnetworkaccessmanager put request.

i formed required json data , stored in qjsondocument variable. , passed variable(after converting utf-8 encoded json document using tojson() ) in put request.

here working test code use believe helpful attempting this.

qvariantmap testmapdata["age"] = 35; qjsondocument testjsondata = qjsondocument::fromvariant(testmapdata);  qnetworkaccessmanager manager;  qnetworkrequest request(qurl("http://example/member/14")); request.setheader(qnetworkrequest::contenttypeheader, qstring("application/json"));  qnetworkreply* reply = manager.put(request, testjsondata.tojson()); 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -