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,
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
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:
"value": "02 98 cb d8 00 15 2 b 02 0f 80 23", // NB: or the base64 value, nvm
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 ..
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
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
Thank you so much !!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.