I want to get a response from the server. I am making a rest api request using "Qt C++" framework. I am able to connect to the server but not able to get the response. The jazz server supports only xml format. I am a beginner in qt.
.pro
QT += widgets
TEMPLATE += app
CONFIG += c++17 console
CONFIG -= app_bundle
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated
before Qt 6.0.0
SOURCES += \
main.cpp
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
HEADERS += \
main.h
main.h
#ifndef MAIN_H
#define MAIN_H
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkReply>
#include <QApplication>
class MyObject : public QObject {
Q_OBJECT
public:
explicit MyObject(QApplication* application);
void TestConnection() const;
static void ReplyFinished(QNetworkReply *reply);
QNetworkAccessManager *manager;
};
#endif // MAIN_H
main.cpp
#include <iostream>
#include "main.h"
MyObject::MyObject(QApplication* app) {
manager = new QNetworkAccessManager(app);
}
void MyObject::TestConnection() const {
auto status = connect(manager, &QNetworkAccessManager::finished,
this, &MyObject::ReplyFinished);
qDebug() << "Connection status:" << status;
manager->get(QNetworkRequest(QUrl("www.jazz.net")));
}
void MyObject::ReplyFinished(QNetworkReply *reply) {
QString answer = reply->readAll();
qDebug() << answer;
QApplication::quit();
}
int main(int argc, char *argv[]) {
auto *app = new QApplication(argc, argv);
auto myObject = new MyObject(app);
myObject->TestConnection();
return QApplication::exec();
}
The output is :
Connection status: true
qt.tlsbackend.ossl: Failed to load libssl/libcrypto.
"" //The response is empty
Note: I am looking for a specific request-response to the jazz server and the URL format is {format: https://:/}