Qt and Octopart API
-
Hello everyone.
Currently i'm trying to develop a software that will use the Octopart API (https://octopart.com/api/docs/v3/overview#search), i need to make request s to the API server and get the JSON data from it. Unfortunately i dont know where to start with that. I already read some tutorials about http requests but didn't understand how to use that. Can someone point me a god tutorial or book about it?
Thanks in advance.
-
QNetworkAccessmanager should be enough to deal with http requests and replays. for JSON see http://doc.qt.io/qt-5/json.html
-
So, i used the following code, just to see if i get a response.
QNetworkAccessManager *manager = new QNetworkAccessManager(this); connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); manager->get(QNetworkRequest(QUrl("https://octopart.com/api/v3/parts/103cdb613d20cffb?apikey=EXAMPLE_KEY")));
But i get the following errors:
qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_client_method
qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_client_method
qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_server_method
qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_server_method
qt.network.ssl: QSslSocket: cannot resolve SSL_select_next_proto
qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_next_proto_select_cb
qt.network.ssl: QSslSocket: cannot resolve SSL_get0_next_proto_negotiated
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_get0_next_proto_negotiatedDoes anyone knows the solution for this?
Thanks.
-
Hi and welcome to devnet,
What OS are you on ?
I'm guessing Windows. If that's the case, did you install OpenSSL on your machine ?
-
What OS are you running ?
-
@jemazter said in Qt and Octopart API:
I installed OpenSSL but i keep getting the same errors
Following is important here:
- what version of OpenSSL?
- is the path to the OpenSSL DLLs in the PATH env variable, so the application can find and load it? Alternatively you can copy the 2 DLLs right next to your application exe (or to be more specific here: into the current working directory, which might not necessarily be the directory the exe is in when starting the application from QtCreator for example)
-
@raven-worx said in Qt and Octopart API:
@jemazter said in Qt and Octopart API:
I installed OpenSSL but i keep getting the same errors
Following is important here:
- what version of OpenSSL?
- is the path to the OpenSSL DLLs in the PATH env variable, so the application can find and load it? Alternatively you can copy the 2 DLLs right next to your application exe (or to be more specific here: into the current working directory, which might not necessarily be the directory the exe is in when starting the application from QtCreator for example)
Hi.
I installed v1.1.0c. I installed it using an executable from this page (slproweb.com/products/Win32OpenSSL.html). Which DLLs should i copy to project folder?
Thanks.
-
@jemazter
OpenSSL 1.1.x support is still missing...see QTBUG-52905
You need to stick to OpenSSL 1.0.x for now. -
I installed v1.0.2j, copied the DLLs to project folder, and still the same errors.
Sorry for the many questions, i'm a newbie to Qt and this is the first "complicated project" i'm doing om my own.
-
@jemazter said in Qt and Octopart API:
I installed v1.0.2j, copied the DLLs to project folder, and still the same errors.
as i said before, this approach still has some pitfalls. You can do this once your application is ready for release.
For now it's easier to add the path to DLLs to the PATH variable, and make sure you restart QtCreator after doing this.
If you don't want to change the system env variables, you can also set the PATH variable in QtCreator directly, then they only take effect for the started application (from within QtCreator). -
Thanks to everybody for the help.
I found out that the errors Qt was showing could be ignored for my application. I probably had other errors in my code, because of that i had no responses from the server, that led me to believe that that errors were the cause to no response from the server.
I was researching about network use in Qt and found this tutorial that coud be useful in the future for someone viewing this thread. It really solved some doubts and it worked here with Octopart API Server. (https://youtu.be/_gSC60y8woA)