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. Error in HTTP request a URL and post data on it
Forum Updated to NodeBB v4.3 + New Features

Error in HTTP request a URL and post data on it

Scheduled Pinned Locked Moved Solved General and Desktop
16 Posts 6 Posters 4.5k Views 4 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.
  • JKSHJ Online
    JKSHJ Online
    JKSH
    Moderators
    wrote on last edited by JKSH
    #6

    @isan said in Error in HTTP request a URL:

    In my web browser(like google chrome), I checked only the address validation ,
    In my code I would request a URLs and put data on it with QNetworkAccessManager

    When you visit a page with a web browser, you are using HTTP GET, not HTTP POST.

    @SGaist is trying to tell you to replace QNetworkAccessManager::post() with QNetworkAccessManager::get().

    See https://www.w3schools.com/tags/ref_httpmethods.asp for a more detailed explanation.

    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

    I 1 Reply Last reply
    2
    • JKSHJ JKSH

      @isan said in Error in HTTP request a URL:

      In my web browser(like google chrome), I checked only the address validation ,
      In my code I would request a URLs and put data on it with QNetworkAccessManager

      When you visit a page with a web browser, you are using HTTP GET, not HTTP POST.

      @SGaist is trying to tell you to replace QNetworkAccessManager::post() with QNetworkAccessManager::get().

      See https://www.w3schools.com/tags/ref_httpmethods.asp for a more detailed explanation.

      I Offline
      I Offline
      isan
      wrote on last edited by isan
      #7

      @JKSH tnx but I want to send data to a server in my code so I use QNetworkAccessManager::post()
      Like I said before , I checked only the address validation ,in my browser because I get server replied: Not Found from the code

      JKSHJ 1 Reply Last reply
      0
      • I isan

        @JKSH tnx but I want to send data to a server in my code so I use QNetworkAccessManager::post()
        Like I said before , I checked only the address validation ,in my browser because I get server replied: Not Found from the code

        JKSHJ Online
        JKSHJ Online
        JKSH
        Moderators
        wrote on last edited by
        #8

        @isan said in Error in HTTP request a URL and put data on it:

        I get server replied: Not Found

        Check the documentation of the server.

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        I 1 Reply Last reply
        1
        • JKSHJ JKSH

          @isan said in Error in HTTP request a URL and put data on it:

          I get server replied: Not Found

          Check the documentation of the server.

          I Offline
          I Offline
          isan
          wrote on last edited by
          #9

          @JKSH said in Error in HTTP request a URL and put data on it:

          Check the documentation of the server.

          My code has not a problem?
          where can I check the documentation of the server?

          JKSHJ 1 Reply Last reply
          0
          • I isan

            @JKSH said in Error in HTTP request a URL and put data on it:

            Check the documentation of the server.

            My code has not a problem?
            where can I check the documentation of the server?

            JKSHJ Online
            JKSHJ Online
            JKSH
            Moderators
            wrote on last edited by
            #10

            @isan said in Error in HTTP request a URL and put data on it:

            My code has not a problem?

            I don't know.

            First, you must find out how the server expects you to send data. Then, you must write your code in a way that your server can understand.

            where can I check the documentation of the server?

            From the server's website, probably.

            @isan said in Error in HTTP request a URL and put data on it:

            I checked only the address validation ,in my browser because I get server replied: Not Found from the code

            You validated that the server allows HTTP GET at this address. Does the server allow HTTP POST at this address?

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            I 2 Replies Last reply
            3
            • JKSHJ JKSH

              @isan said in Error in HTTP request a URL and put data on it:

              My code has not a problem?

              I don't know.

              First, you must find out how the server expects you to send data. Then, you must write your code in a way that your server can understand.

              where can I check the documentation of the server?

              From the server's website, probably.

              @isan said in Error in HTTP request a URL and put data on it:

              I checked only the address validation ,in my browser because I get server replied: Not Found from the code

              You validated that the server allows HTTP GET at this address. Does the server allow HTTP POST at this address?

              I Offline
              I Offline
              isan
              wrote on last edited by isan
              #11

              @JKSH I know that the data format should be:
              Value, date, time like 166,2019/02 /11,3: 34: 45
              The server manager tells me that I can POST data in it

              Pablo J. RoginaP 1 Reply Last reply
              0
              • I isan

                @JKSH I know that the data format should be:
                Value, date, time like 166,2019/02 /11,3: 34: 45
                The server manager tells me that I can POST data in it

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

                @isan a couple of things here...

                1. Would you mind editing your post title to reflect you're trying to "post" data instead of put
                2. Are you able to post any JSON data to that URL using any other tool? i.e. curl
                  See here for an example how to post JSON data from command line with curl just in case.
                3. You should avoid any loop messing with Qt event loop. You should instead connect signals finished() and error(). See here for instance
                while(!reply->isFinished()) {
                    qApp->processEvents();
                    }
                
                1. It looks like the array data you're sending is not a valid JSON construct. You can use this online tool to check for JSON validity. That could be the cause of server rejection of your request.
                Error: Parse error on line 1:
                [158, 2019 / 02 / 10, 10: 48: 5
                -----------^
                Expecting 'EOF', '}', ',', ']', got 'undefined'
                

                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

                I 1 Reply Last reply
                2
                • JKSHJ JKSH

                  @isan said in Error in HTTP request a URL and put data on it:

                  My code has not a problem?

                  I don't know.

                  First, you must find out how the server expects you to send data. Then, you must write your code in a way that your server can understand.

                  where can I check the documentation of the server?

                  From the server's website, probably.

                  @isan said in Error in HTTP request a URL and put data on it:

                  I checked only the address validation ,in my browser because I get server replied: Not Found from the code

                  You validated that the server allows HTTP GET at this address. Does the server allow HTTP POST at this address?

                  I Offline
                  I Offline
                  isan
                  wrote on last edited by isan
                  #13

                  @JKSH said in Error in HTTP request a URL and post data on it:

                  You validated that the server allows HTTP GET at this address. Does the server allow HTTP POST at this address?

                  The server did not allow and the server administrator had made a mistake
                  thank you

                  S 1 Reply Last reply
                  0
                  • Pablo J. RoginaP Pablo J. Rogina

                    @isan a couple of things here...

                    1. Would you mind editing your post title to reflect you're trying to "post" data instead of put
                    2. Are you able to post any JSON data to that URL using any other tool? i.e. curl
                      See here for an example how to post JSON data from command line with curl just in case.
                    3. You should avoid any loop messing with Qt event loop. You should instead connect signals finished() and error(). See here for instance
                    while(!reply->isFinished()) {
                        qApp->processEvents();
                        }
                    
                    1. It looks like the array data you're sending is not a valid JSON construct. You can use this online tool to check for JSON validity. That could be the cause of server rejection of your request.
                    Error: Parse error on line 1:
                    [158, 2019 / 02 / 10, 10: 48: 5
                    -----------^
                    Expecting 'EOF', '}', ',', ']', got 'undefined'
                    
                    I Offline
                    I Offline
                    isan
                    wrote on last edited by
                    #14

                    @Pablo-J.-Rogina thanks

                    1 Reply Last reply
                    0
                    • I isan

                      @JKSH said in Error in HTTP request a URL and post data on it:

                      You validated that the server allows HTTP GET at this address. Does the server allow HTTP POST at this address?

                      The server did not allow and the server administrator had made a mistake
                      thank you

                      S Offline
                      S Offline
                      Stephen28
                      wrote on last edited by
                      #15

                      @isan how did you solved this bro?
                      i mean how did you made server get allowed?

                      JonBJ 1 Reply Last reply
                      0
                      • S Stephen28

                        @isan how did you solved this bro?
                        i mean how did you made server get allowed?

                        JonBJ Online
                        JonBJ Online
                        JonB
                        wrote on last edited by
                        #16

                        @Stephen28
                        By (a) checking the particular server you are using to do whatever to allow GETs on the appropriate URL and (b) checking the server application to make sure it accepts GETs and responds accordingly.

                        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