I want to send data through a post request but only those who are authenticated can do it. In django application I added the BasicAuthentication in settings.py
...
REST_FRAMEWORK = {
'PAGE_SIZE': 10,
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.BasicAuthentication',
)
}
and in Qt post authenticated to do so
...
QNetworkRequest request;
QUrl url("https://.../data/");
url.setUserInfo("username:password");
request.setUrl(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QString json = QString(...);
QNetworkReply *reply = m_manager->post(request, json.toUtf8());
...
As an error the server returns me -> Error transferring https://username:password@.../data/ - server replied: Bad Request.
I can not understand whether the problem lies in the way in which pass username: password or django app.