How to use HTTP JSON Receiever to receive the data with is by JSON format
-
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
-
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"
Secondly, I tried to run two http post as below,
first one, I put content type as application/json,
Second one, I put content type as what you recommend above, result get is unconsumed key
For these two tests, I can not get the data from data view as below.
Thanks,
Wilson -
Would you please help explain more about below, Thank you.
#!/bin/bash
#Send previous POST to the server!
nc serverIp serverPort < postMessage.txt -
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.
-
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.
-
@phildunlap I just wanting your sample file, When will you finish your traveling ?
-
What sample file? The contents of "postMessage.txt" was the text in the higher part of the post.
-
After running the script "
nc localhost 8080 < postMessage.txt" , it have the error, attach the error.txt for reference : 0_1486449341741_error.txt -
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
-
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.