# How can I recover a json message from a distant server?

**URL:** <https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217>\
**Category:** General\
**Created:** [28 October 2019 07:35 UTC](https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217 "2019-10-28T07:35:59Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris35](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@chris35](https://discourse.nodered.org/u/chris35)\
**Post date:** [28 October 2019 07:35 UTC](https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217/1 "2019-10-28T07:35:59Z")

</div>

I would like to recover a JSON message in node-red from a distant server

I've tried with a node "tcp-in"

but I don't know if it's a good solution because I don't have only the JSON....

what's the node better for me ?

I want to extract json part in a message with node red

I receive the message in node red but I can't extract the data  
exemple of message:

```auto
POST / HTTP/1.1

Host: xxx.xx.xxx.5:9000

User-Agent: libcurl-agent/1.0

Content-type: application/json

Accept: application/json

Content-Length: 526   
   {
   "timestamp": 1571997083,
   "data": {
      "temperature": 20.613545532227,
      "humidity": 61.3828125,
      "battery": 3.47
   },
   "frame": "814962xxxx16a1dc5",
   "gatewayID": "AA555Axxxx0xx964",
   "othersGW": [],
   "clientID": "xxxx",
   "DevAddr": "011xxxxb",
   "DevEUI": "8cf9xxx000000xxx",
   "sensorInstallId": "8cf95xxx0000xxxx",
   "loraPort": 8,
   "fcnt": 1607,
   "rxpk": {
      "tmst": 2380181019,
      "time": "2019-10-25T09:51:23.472998Z",
      "chan": 0,
      "rfch": 0,
      "freq": 867.1,
      "stat": 1,
      "modu": "LORA",
      "datr": "SF7BW125",
      "codr": "4/5",
      "lsnr": 9,
      "rssi": -72,
      "size": 22,
      "data": "xxxxxxxxxxxxxxxx/YxWg=="
   }
}

```

so I would like to have data of temperature etc... and I don't know the node I have to use

Thanks a lot

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [28 October 2019 07:56 UTC](https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217/2 "2019-10-28T07:56:34Z")

</div>

You can receive data from the device using curl ?  
In node-red you can use the http request node.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [28 October 2019 08:02 UTC](https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217/3 "2019-10-28T08:02:56Z")

</div>

Hi, you asked this same question on stack overflow a couple days ago and received a lot of replies there.

If the remote server is sending it as an http request to your Node-RED instance then you should use the HTTP In node to receive it which will parse the response and the values you want will be in `msg.payload`.

---

<div class="post-metadata">

**Author:** ![chris35](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@chris35](https://discourse.nodered.org/u/chris35)\
**Post date:** [28 October 2019 08:15 UTC](https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217/4 "2019-10-28T08:15:04Z")

</div>

thank you but if I ask the question on the forum nodered as indicated is that I can not do it ...  
and I'm looking for help.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [28 October 2019 08:28 UTC](https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217/5 "2019-10-28T08:28:19Z")

</div>

But you have asked exactly the same question and ignored all the answers you have received. So now you will get a lot of the same answers because we don't know what you have tried.

Have you tried the HTTP In node to receive the request? If not, why not? If you have, then what problem did you hit?

---

<div class="post-metadata">

**Author:** ![chris35](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@chris35](https://discourse.nodered.org/u/chris35)\
**Post date:** [28 October 2019 12:50 UTC](https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217/6 "2019-10-28T12:50:42Z")

</div>

yes I have tried the HTTP IN but doesn't work

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [28 October 2019 12:54 UTC](https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217/7 "2019-10-28T12:54:56Z")

</div>

> [@chris35](#):
>
> but doesn't work

Can you explain what part of it does not work? By stating "doesn't work" without additional information, for example on how you used it and what your flow looked like we can't offer suggestions on how to fix it to make it work in the end.

---

<div class="post-metadata">

**Author:** ![JayDickson](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jaydickson/32/90592_2.png) [@JayDickson](https://discourse.nodered.org/u/JayDickson)\
**Post date:** [28 October 2019 12:55 UTC](https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217/8 "2019-10-28T12:55:45Z")

</div>

[https://nodered.org/docs/user-guide/messages](https://nodered.org/docs/user-guide/messages)

---

<div class="post-metadata">

**Author:** ![chris35](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@chris35](https://discourse.nodered.org/u/chris35)\
**Post date:** [28 October 2019 13:32 UTC](https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217/9 "2019-10-28T13:32:59Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/6384a12a1baa58ea11c55cbd914ed91d5f2c7002.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/7f8ebbb8bd227836b018bbc5fba889c3164f3312.png)

I've nothing in debug  
but I can read a message when I listen the port 9000 with the "TCP IN"

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [28 October 2019 13:44 UTC](https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217/10 "2019-10-28T13:44:31Z")

</div>

Could you set the debug node to show the complete msg object ?

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [28 October 2019 13:52 UTC](https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217/11 "2019-10-28T13:52:21Z")

</div>

> [@chris35](#):
>
> but I can read a message when I listen the port 9000 with the "TCP IN"

Can you try to explain how you think the HTTP-In node works, because based on your screenshot and this message I think you have a different working in mind than how it works.  
Take a look at the following from the built-in description for this node:

 ![14](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/5/50108193c50db9f0f3bd1f352dda66e1fcea8808.png)

The following is an example from one of my own flows in creating a callback for a Spotify OAuth request. It includes an `HTTP In` node, various in-betweens for doing the requested action, and an `HTTP Response` node.

 ![23](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/41825b1c5ea1b0c494b2d3dbbc6f7cdc18d88721.png) ![35](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/4b6f677df9cb7b1c6ed9c5219cd52522a5f9ca26.png)

What is going on here is that when I go to the address my device is on, with the path `/oauth/neela/spotify-callback` that flow is triggered, and in the end the payload coming in to the `http (200)` node in the flow shown is posted back in the page that is requested.

Does this kind of behaviour match the thing you're trying to do, or not at all?

---

<div class="post-metadata">

**Author:** ![chris35](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@chris35](https://discourse.nodered.org/u/chris35)\
**Post date:** [28 October 2019 14:09 UTC](https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217/12 "2019-10-28T14:09:02Z")

</div>

in fact... that's what I said in my first message :a server push me a message

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/85134b1289b9b511c16f8b9cf13f1257dfbadd6c.png)  
I can read on the port 9000 this message:

```auto
POST / HTTP/1.1

Host: xxx.xx.xxx.5:9000

User-Agent: libcurl-agent/1.0

Content-type: application/json

Accept: application/json

Content-Length: 526   
   {
   "timestamp": 1571997083,
   "data": {
      "temperature": 20.613545532227,
      "humidity": 61.3828125,
      "battery": 3.47
   },
   "frame": "814962xxxx16a1dc5",
   "gatewayID": "AA555Axxxx0xx964",
   "othersGW": [],
   "clientID": "xxxx",
   "DevAddr": "011xxxxb",
   "DevEUI": "8cf9xxx000000xxx",
   "sensorInstallId": "8cf95xxx0000xxxx",
   "loraPort": 8,
   "fcnt": 1607,
   "rxpk": {
      "tmst": 2380181019,
      "time": "2019-10-25T09:51:23.472998Z",
      "chan": 0,
      "rfch": 0,
      "freq": 867.1,
      "stat": 1,
      "modu": "LORA",
      "datr": "SF7BW125",
      "codr": "4/5",
      "lsnr": 9,
      "rssi": -72,
      "size": 22,
      "data": "xxxxxxxxxxxxxxxx/YxWg=="
   }
}

```

that I want to do is to extract data like temperature .... and I don't know what node to use

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [28 October 2019 14:16 UTC](https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217/13 "2019-10-28T14:16:58Z")

</div>

@chris35 again, use the HTTP In node. The example you shared where you tried to use it is incorrectly configured and will not work. @afelix has tried to show you where you went wrong, but you do not appear to have read her reply fully.

1. Add an HTTP In node.
2. Configure the URL to be `/my-data` and the method to be `POST`.
3. Configure the remote system to send its request to `http://<ip-of-machine-running-node-red>/my-data`
4. Connect the HTTP In node to a Debug node

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [28 October 2019 14:20 UTC](https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217/14 "2019-10-28T14:20:08Z")

</div>

> [@chris35](#):
>
> that I want to do is to extract data like temperature .... and I don't know what node to use

Here is a method to get at the JSON

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/870b89d30cc0be33149df98b95d833174d255f0a.png)

```auto
[{"id":"c07cfd49.9ee07","type":"inject","z":"3da0d845.11d708","name":"","topic":"","payload":"POST / HTTP/1.1 Host: xxx.xx.xxx.5:9000 User-Agent: libcurl-agent/1.0 Content-type: application/json Accept: application/json Content-Length: 526 { \"timestamp\": 1571997083, \"data\": { \"temperature\": 20.613545532227, \"humidity\": 61.3828125, \"battery\": 3.47 }, \"frame\": \"814962xxxx16a1dc5\", \"gatewayID\": \"AA555Axxxx0xx964\", \"othersGW\": [], \"clientID\": \"xxxx\", \"DevAddr\": \"011xxxxb\", \"DevEUI\": \"8cf9xxx000000xxx\", \"sensorInstallId\": \"8cf95xxx0000xxxx\", \"loraPort\": 8, \"fcnt\": 1607, \"rxpk\": { \"tmst\": 2380181019, \"time\": \"2019-10-25T09:51:23.472998Z\", \"chan\": 0, \"rfch\": 0, \"freq\": 867.1, \"stat\": 1, \"modu\": \"LORA\", \"datr\": \"SF7BW125\", \"codr\": \"4/5\", \"lsnr\": 9, \"rssi\": -72, \"size\": 22, \"data\": \"xxxxxxxxxxxxxxxx/YxWg==\" } }","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":666,"y":198,"wires":[["8115857.60bb578"]]},{"id":"4aa31be9.5e95f4","type":"debug","z":"3da0d845.11d708","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1144,"y":198,"wires":[]},{"id":"8115857.60bb578","type":"change","z":"3da0d845.11d708","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"\"{\" & $substringAfter(payload, \"{\")\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":198,"wires":[["67871c2b.8e0334"]]},{"id":"67871c2b.8e0334","type":"json","z":"3da0d845.11d708","name":"","property":"payload","action":"obj","pretty":false,"x":984,"y":198,"wires":[["4aa31be9.5e95f4"]]}]

```

---

<div class="post-metadata">

**Author:** ![chris35](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@chris35](https://discourse.nodered.org/u/chris35)\
**Post date:** [28 October 2019 14:38 UTC](https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217/15 "2019-10-28T14:38:57Z")

</div>

[cymplecy](https://discourse.nodered.org/u/cymplecy) thank's a lot : it works...

---

<div class="post-metadata">

**Author:** ![chris35](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@chris35](https://discourse.nodered.org/u/chris35)\
**Post date:** [28 October 2019 14:41 UTC](https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217/16 "2019-10-28T14:41:00Z")

</div>

ok I will test.... excuse me for my bad english

---

<div class="post-metadata">

**Author:** ![chris35](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@chris35](https://discourse.nodered.org/u/chris35)\
**Post date:** [29 October 2019 09:03 UTC](https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217/17 "2019-10-29T09:03:34Z")

</div>

Hello  
I test the method of knolleary but it's don' t work:  
in the part 2 : I've only to put `/my-data` in URL ? nothing else ?  
in the part 4 : nothing in debug Node

Thanks

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [29 October 2019 09:13 UTC](https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217/18 "2019-10-29T09:13:12Z")

</div>

> [@knolleary](#):
>
> Configure the remote system to send its request to `http://<ip-of-machine-running-node-red>/my-data`

Did you follow step 3 as well?

---

<div class="post-metadata">

**Author:** ![chris35](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@chris35](https://discourse.nodered.org/u/chris35)\
**Post date:** [29 October 2019 09:23 UTC](https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217/19 "2019-10-29T09:23:39Z")

</div>

yes for me it's ok for 3

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [29 October 2019 09:39 UTC](https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217/20 "2019-10-29T09:39:57Z")

</div>

@chris35 Please provide a screenshot of the HTTP In node showing how you have configured it.

[Next page](https://discourse.nodered.org/t/how-can-i-recover-a-json-message-from-a-distant-server/17217.md?page=2)
