# HTTP IN node, retrieve my raw data

**URL:** https://discourse.nodered.org/t/http-in-node-retrieve-my-raw-data/44853
**Category:** General
**Created:** [28 April 2021 09:56 UTC](https://discourse.nodered.org/t/http-in-node-retrieve-my-raw-data/44853 "2021-04-28T09:56:08Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Archi](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@Archi](https://discourse.nodered.org/u/Archi)
#### Post date: [28 April 2021 09:56 UTC](https://discourse.nodered.org/t/http-in-node-retrieve-my-raw-data/44853/1 "2021-04-28T09:56:08Z")

</div>

Hello everyone,

I'm new on Node-red and I'm struggling for now 1 week on a simple problem.  
To quickly sum up my situation, I'm sending data through an HTTP POST like this:

 ![node_red1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/d/6dd0752a3735c9f3f683ecd8b31c39dde35b26a1.png)

The thing is that I need to retrieve my data from the HEX packet of my payload, and not from the text interpretation. For example, here my data is **02 98 cb d8 00 15 2b 02 0f 80 23**. But I'm not able to retrieve it, since node-red is always interpreting my **02 98 cb d8 00 15 2b 02 0f 80 23** as a string when it arrive on Node-Red.

For example, **02 98 cb d8 00 15 2b 02 0f 80 23** is interpreted as follow:

![node_red2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/6/1633bc739d7eae8c2c5ba208a63bfcec85e5f292.png)

And when I try to pass it in a buffer it give me **02 ef bf bd ef bf bd ef bf bd 00 15 2b 02 0f ef bf bd 23** instead of **02 98 cb d8 00 15 2 b 02 0f 80 23**.

to conclude, I'm not able to get my "true" data at the moment.  
So, do you guys have any idea about how to proceed to get the binary/raw data from the post ?

Thanks you in advance,  
Regards,  
Cédric R

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [28 April 2021 10:18 UTC](https://discourse.nodered.org/t/http-in-node-retrieve-my-raw-data/44853/2 "2021-04-28T10:18:36Z")

</div>

Hi, by the sounds of it, you are in control of what is being sent - so what does the byte data actually represent?

for example, assuming the data is 2xUINT32s, 1xUINT16 and 1xbyte (i am guessing) why not simply send JSON

e.g. `{"item1":3637221378,"item2":36377856,"item3":32783,"item4":35}`

then the values of the payload can be easily used in your flow as a native JS object.

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

If instead you insist of sending binary data, you could convert it to base64 (`"ApjL2AAVKwIPgCM="`) in your sending application and use the base64 node to convert it back to a buffer in node-red.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/0/b042ada4bbd45b19e0cb1ff91a46604e980698b0.png)

---

<div class="post-metadata">

### Author: ![Archi](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@Archi](https://discourse.nodered.org/u/Archi)
#### Post date: [28 April 2021 10:51 UTC](https://discourse.nodered.org/t/http-in-node-retrieve-my-raw-data/44853/3 "2021-04-28T10:51:34Z")

</div>

Hi, thanks for your answer.

It's not that simple, I would want to retrieve the data **02 98 cb d8 00 15 2 b 02 0f 80 23** to resend it in a new formed HTTP packet.

At the end, I use an HTTP request to send a JSON payload to another server, like:

```auto
{   
"deviceid": "abcde",
"value": "02 98 cb d8 00 15 2 b 02 0f 80 23", // NB: or the base64 value, nvm 
"devicetype": "SomeSensor"
}

```

So it's like if I was using node-red as an HTTP to HTTP proxy where I'm doing some treatment on my payload. And to do it I need to be able to retrieve the "raw payload".

All the work to achieve is about this hex payload "hidden" in the packet .. 😕

---

<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 April 2021 10:56 UTC](https://discourse.nodered.org/t/http-in-node-retrieve-my-raw-data/44853/4 "2021-04-28T10:56:45Z")

</div>

It doesn't look like you are setting the `content-type` header on the request. Without that header, NR has to guess at the type of content being sent and, in this case, is incorrectly interpreting it as a string.

If you can set the `content-type` to `application/octet-stream` then NR will know to treat it as the raw bytes and pass it on as a Buffer object.

---

<div class="post-metadata">

### Author: ![Archi](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@Archi](https://discourse.nodered.org/u/Archi)
#### Post date: [28 April 2021 10:59 UTC](https://discourse.nodered.org/t/http-in-node-retrieve-my-raw-data/44853/5 "2021-04-28T10:59:54Z")

</div>

Thanks for your answer, I'll try this !

---

<div class="post-metadata">

### Author: ![Archi](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@Archi](https://discourse.nodered.org/u/Archi)
#### Post date: [28 April 2021 12:34 UTC](https://discourse.nodered.org/t/http-in-node-retrieve-my-raw-data/44853/6 "2021-04-28T12:34:14Z")

</div>

It's now working with the header `content-type: application/octet-stream`

Thank you so much !!

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [12 May 2021 12:35 UTC](https://discourse.nodered.org/t/http-in-node-retrieve-my-raw-data/44853/7 "2021-05-12T12:35:06Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
