Hii everyone
I'm using Redmine Rest API for my project, I can create, update, delete, ... (Users, Projects, ...) using POST, GET, PUT, DELETE
I want to get the response from Redmine if create (for example) was OK
From Redmine documentation :
Response:
201 Created: user was created
422 Unprocessable Entity: user was not created due to validation failures (response body contains the error messages)
Redmine REST API screenshot : Capture du 2016-05-23 12:23:19.png
Qt Code :
QNetworkReply *reply = manager->post(request, dataByteArray);
/* The finished() signal is triggered once an HTTP request is complete, by connect method we are connecting finished signal with the slot method onRequestFinished(user defined method). If it returns true it means connection is successful else not. You can process the response of the call in this user defined method */
result = connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(onRequestFinished(QNetworkReply*)));
// Create user : ok
QNetworkReply *reply = manager->post(request, dataByteArray);
/* The finished() signal is triggered once an HTTP request is complete, by connect method we are connecting finished signal with the slot method onRequestFinished(user defined method). If it returns true it means connection is successful else not. You can process the response of the call in this user defined method */
result = connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(onRequestFinished(QNetworkReply*)));
// Create user : ok
To copy to clipboard, switch view to plain text mode
void TestClass::onRequestFinished(QNetworkReply* reply)
{
QString strReply
= reply
->readAll
();
qDebug() << strReply;
}
void TestClass::onRequestFinished(QNetworkReply* reply)
{
QString strReply = reply->readAll();
qDebug() << strReply;
}
To copy to clipboard, switch view to plain text mode
strReply : contains the json response : name, email, ...
So how can I get the response from Redmine : 201 Created or 422 Unprocessable Entity ??
Thanks
Bookmarks