Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to connect via API?
Forum Updated to NodeBB v4.3 + New Features

How to connect via API?

Scheduled Pinned Locked Moved Solved General and Desktop
66 Posts 8 Posters 14.1k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mikeeeeee
    wrote on last edited by
    #34

    Not check. I don't know what other resource to connect to.

    jsulmJ Pablo J. RoginaP 2 Replies Last reply
    0
    • M Mikeeeeee

      Not check. I don't know what other resource to connect to.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #35
      This post is deleted!
      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mikeeeeee
        wrote on last edited by
        #36

        How to fix this error?

        1 Reply Last reply
        0
        • M Mikeeeeee

          Not check. I don't know what other resource to connect to.

          Pablo J. RoginaP Offline
          Pablo J. RoginaP Offline
          Pablo J. Rogina
          wrote on last edited by
          #37

          @Mikeeeeee you may try a JSON testing site with secure connections, like https://jsonplaceholder.typicode.com

          i.e. https://jsonplaceholder.typicode.com/todos/1 will return:

          {
            "userId": 1,
            "id": 1,
            "title": "delectus aut autem",
            "completed": false
          }
          

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Mikeeeeee
            wrote on last edited by
            #38

            @Pablo-J.-Rogina said in How to connect via API?:

            https://jsonplaceholder.typicode.com/todos/1

            Tried to send to this address and got an old error.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              Mikeeeeee
              wrote on last edited by
              #39

              And if you sent"http://json placeholder.typecode.com/todos/1" it works. Why https doesn't work?

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #40

                Just to be sure add this to your code:

                qDebug() << QSslSocket::supportsSsl();
                qDebug() << QSslSocket::sslLibraryBuildVersionString();
                qDebug() << QSslSocket::sslLibraryVersionString();
                

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1
                • M Offline
                  M Offline
                  Mikeeeeee
                  wrote on last edited by
                  #41

                  qDebug returns:
                  qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
                  false
                  "OpenSSL 1.0.2p 14 Aug 2018"

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #42

                    Are you sure you put the OpenSSL 1.0 dlls in the right folder ? Without mixing them with another version of OpenSSL.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      Mikeeeeee
                      wrote on last edited by
                      #43

                      Sure. Here is the contents of the folder:
                      0_1558769898345_1.png

                      1 Reply Last reply
                      0
                      • mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #44

                        hi
                        I wonder if it also wants libssl32.dll ?

                        1 Reply Last reply
                        0
                        • I Offline
                          I Offline
                          IRayman
                          wrote on last edited by
                          #45

                          hey @Mikeeeeee,

                          You can try those .dll. I used it few weeks ago when I needed Qt SSL on Windows and it worked fine.

                          https://anonfile.com/m2Z7N6s6nd/dll_zip

                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            Mikeeeeee
                            wrote on last edited by SGaist
                            #46

                            Thanks. https is working.
                            Trying to use the function TIME_SERIES_DAILY_ADJUSTED.
                            https://www.alphavantage.co/documentation/
                            If you do so it works:

                            request.setUrl(QUrl("https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=MSFT&outputsize=compact&apikey=XXXXXXXXXXXXX"));
                            

                            If doing so does not work:

                            request.setUrl(QUrl("https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=MSFT&outputsize=full&apikey=XXXXXXXXXXXXXXX"));
                            

                            It's me doing something wrong or the server is not working?

                            [edit: removed API key SGaist]

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #47

                              Since you don't show how you are processing the QNetworkReply object created for your request one can only guess. What signals did you connect from the reply object ? What exactly do you mean by "does not work" ?

                              By the way, I've edited out your api key, it's not a good idea to post such information.

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply
                              1
                              • M Offline
                                M Offline
                                Mikeeeeee
                                wrote on last edited by
                                #48

                                It's my h-file:

                                private slots:
                                    void on_testButton_clicked();
                                    void testSlotFromQDebug();
                                    void onReply(QNetworkReply* reply);
                                
                                private:
                                    Ui::MainWindow *ui;
                                    QNetworkAccessManager *apiQuery = new QNetworkAccessManager;
                                

                                it's cpp-file:```
                                #include "mainwindow.h"
                                #include "ui_mainwindow.h"

                                MainWindow::MainWindow(QWidget *parent) :
                                QMainWindow(parent),
                                ui(new Ui::MainWindow)
                                {
                                ui->setupUi(this);

                                //connect(apiQuery, &QNetworkAccessManager::finished, this, &MainWindow::testSlotFromQDebug);
                                

                                }

                                MainWindow::~MainWindow()
                                {
                                delete ui;
                                }

                                void MainWindow::on_testButton_clicked()
                                {
                                QNetworkRequest request;
                                //request.setUrl(QUrl("https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=MSFT&apikey=demo"));
                                request.setUrl(QUrl("https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=MSFT&outputsize=full&apikey=111111"));
                                //request.setUrl(QUrl("https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=MSFT&outputsize=compact&apikey=1111"));

                                QNetworkReply* reply = apiQuery->get(request);
                                connect(reply ,&QNetworkReply::finished,this,std::bind(&MainWindow::onReply,this,reply ));
                                

                                }

                                void MainWindow::testSlotFromQDebug()
                                {
                                //qDebug()<<"point1";
                                }

                                void MainWindow::onReply(QNetworkReply* reply){
                                QJsonDocument jdoc = QJsonDocument::fromJson(reply->readAll());
                                //qDebug() << QSslSocket::supportsSsl();
                                //qDebug() << QSslSocket::sslLibraryBuildVersionString();
                                //qDebug() << QSslSocket::sslLibraryVersionString();
                                qDebug()<<jdoc;
                                // do something with the jdoc
                                }

                                1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #49

                                  Again: what do you mean by "it's not working" when using the full output size ?

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  0
                                  • M Offline
                                    M Offline
                                    Mikeeeeee
                                    wrote on last edited by Mikeeeeee
                                    #50

                                    Nothing comes back. I do not receive json document.

                                    1 Reply Last reply
                                    0
                                    • SGaistS Offline
                                      SGaistS Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #51

                                      What about connecting the errors related signals ? That might give you some clues about what is happening.

                                      Interested in AI ? www.idiap.ch
                                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      1 Reply Last reply
                                      0
                                      • M Offline
                                        M Offline
                                        Mikeeeeee
                                        wrote on last edited by
                                        #52

                                        But what signals and slots to use to find the error?

                                        1 Reply Last reply
                                        0
                                        • M Offline
                                          M Offline
                                          Mikeeeeee
                                          wrote on last edited by
                                          #53
                                          This post is deleted!
                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved