c++qtqnetworkaccessmanager

How do I send payload via a QNetworkAccessManager for post?


I'm using Qt::QNetworkAccessManager for simulating web post.

QNetworkReply *QNetworkAccessManager::post(const QNetworkRequest &request, const QByteArray &data)

enter image description here

This is a request track on a broswer. How can I send those request payload which are in json format.


Solution

  • I found this Correct format for HTTP POST using QNetworkRequest

    QByteArray jsonString = "{\"method\":\"AuthenticatePlain\",\"loginName\":\"username@domain.com\",\"password\":\"mypass\"}";
    
    QNetworkReply * reply = m_qnam->post(request, jsonString);