HTTP IN node, retrieve my raw data

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:

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:


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,
CĂ©dric R

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.


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.


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:

"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 .. :confused:

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.

Thanks for your answer, I'll try this !

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

Thank you so much !!

1 Like

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