• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    How to use HTTP JSON Receiever to receive the data with is by JSON format

    How-To
    4
    16
    6.6k
    Loading More Posts
    • 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.
    • phildunlapP
      phildunlap
      last edited by

      Here is a simple sample HTTP message that can be passed to the receiver,

      POST /httpds HTTP/1.1
      Content-Type: application/x-www-form-urlencoded
      Connection: Keep-Alive
      Host: localhost
      Content-Length: 19
      Accept: */*
      
      json={"test":false}
      
      #!/bin/bash
      #Send previous POST to the server!
      nc serverIp serverPort < postMessage.txt
      
      W 1 Reply Last reply Reply Quote 0
      • Hui Ka KamH
        Hui Ka Kam
        last edited by Hui Ka Kam

        Dear phildunlap

        • Where can I found the in-Mango help by opening the dialogue for the HTTP Json receiver point?

        • Can you please help to make a sample data sources and data point to me that I can import to our system to test the result, It look too difficult about this article.

        Thx
        Kam

        1 Reply Last reply Reply Quote 0
        • phildunlapP
          phildunlap
          last edited by

          It is the blue help question mark (?) on the data point's edit page, at the top of the data point edit section.

          I would normally post JSON for a data source, but I am traveling at the moment, so I'll have to add that in later. It should be pretty easy though. For the sample message in my last post, the data type is Binary and the Parameter Name is test

          1 Reply Last reply Reply Quote 0
          • W
            Wilson @phildunlap
            last edited by joeamiraglia

            @phildunlap

            Hi Phil,

            Thank you but I tried per your advice, result is not optimistic. Please assist.
            Firstly, I created mango http receiver with data point, with most input as "key"
            0_1486093270932_1.jpg
            Secondly, I tried to run two http post as below,
            first one, I put content type as application/json,
            0_1486093377336_2.jpg
            Second one, I put content type as what you recommend above, result get is unconsumed key
            0_1486093603658_3.jpg
            For these two tests, I can not get the data from data view as below.
            0_1486093872378_4.png

            Thanks,
            Wilson

            1 Reply Last reply Reply Quote 0
            • W
              Wilson
              last edited by

              Would you please help explain more about below, Thank you.

              #!/bin/bash
              #Send previous POST to the server!
              nc serverIp serverPort < postMessage.txt

              1 Reply Last reply Reply Quote 0
              • phildunlapP
                phildunlap
                last edited by phildunlap

                Hi Wilson,

                The nc command is just to send those characters to the server at its HTTP port. HTTP is message structuring built on TCP, so for simple messages it is easy enough to use nc (the "TCP/IP Swiss Army Knife") for immediate testing results where absolutely no other factors are in the problem.

                1 Reply Last reply Reply Quote 0
                • phildunlapP
                  phildunlap
                  last edited by

                  There is undoubtably room to improve the HTTP JSON receiver. As I said, it was bolted onto the HTTP receiver because a client was faced with a situation where use of regex to identify points and values would have been impossible. I could conceive value in consuming the post body as one large JSON object (as the receiver outputs for type JSON) as well as having a more sensible relationship to the content-type. The demand simply hasn't existed before.

                  Hui Ka KamH 1 Reply Last reply Reply Quote 0
                  • Hui Ka KamH
                    Hui Ka Kam @phildunlap
                    last edited by

                    @phildunlap I just wanting your sample file, When will you finish your traveling ?

                    1 Reply Last reply Reply Quote 0
                    • phildunlapP
                      phildunlap
                      last edited by

                      What sample file? The contents of "postMessage.txt" was the text in the higher part of the post.

                      1 Reply Last reply Reply Quote 0
                      • Hui Ka KamH
                        Hui Ka Kam
                        last edited by

                        After running the script "
                        nc localhost 8080 < postMessage.txt" , it have the error, attach the error.txt for reference : 0_1486449341741_error.txt

                        1 Reply Last reply Reply Quote 0
                        • phildunlapP
                          phildunlap
                          last edited by phildunlap

                          Hi Kam,

                          Thanks for bringing that to our attention. i bet the point you are using doesn't have a data type of Binary. But, that shouldn't throw an NPE regardless. Your line numbers imply you're using Mango 2.5 ? It shouldn't matter for this data source, since it hasn't really changed in years.

                          I have run my test, again, and am still able to make it work. I have a binary data point with the parameterKey 'test' and I am passing in the following messages:

                          setFalse.txt:

                          POST /httpds HTTP/1.1
                          Accept: */*
                          Content-Type: application/x-www-form-urlencoded
                          Host: 127.0.0.1
                          Connection: Keep-Alive
                          Content-Length: 19
                          
                          json={"test":false}
                          

                          setTrue.txt:

                          GET /httpds?json={"test":true} HTTP/1.1
                          Accept: */*
                          Content-Type: application/json
                          Host: 127.0.0.1
                          Connection: Keep-Alive
                          

                          I am doing:

                          nc 127.0.0.1 80 < setFalse.txt
                          nc 127.0.0.1 80 < setTrue.txt
                          1 Reply Last reply Reply Quote 0
                          • D
                            doriaguiar
                            last edited by

                            try to change localhost to 127.0.0.1

                            I did that and it worked.

                            If you want localhost to work you need to change your hosts file like the picture below.

                            I hope it helps.

                            0_1573330326967_77c22e1f-0df4-485e-a6cc-7e244cffd3be-image.png

                            0_1573330381922_8a54d321-e0ab-4e5d-b192-df7b816dbb23-image.png

                            0_1573330729102_05c34180-4394-4716-9420-67b44be50df1-image.png

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post