Posting binary buffer payload using Node-RED

馋奶兔 提交于 2019-12-12 05:39:00

问题


I am trying to send a byte array through POST using Node-RED. I can successfully create the buffer using this module and storing it in msg.payload. However I can't figure out how to add it as a parameter in a http request node.

The receiving application requires enclosing quotes. So I use the payload in the following url: localhost:port/path?var=\"{{payload}}\", but it gives

"Error converting http params to args: invalid character '\' looking for beginning of value"

If using it in the request url without quotes: localhost:port/path?var={{payload}} nothing gets through (I can see on the other end).

I am using Protobuf due to the application on the other side, but I've also tried creating a buffer, as described here. However, nothing changes.


回答1:


POSTs should not have arguments in the URL. The data should all be in the body.

Do you need to make the msg.payload an object with keys matching the arg names.

msg.payload = {
  var = [buffer]
}

You will probably have to play around with the content-type header as by default I believe Node-RED will send a JSON body and you probably want application/x-www-form-urlencoded

You can set the headers by adding a msg.headers object



来源:https://stackoverflow.com/questions/45695651/posting-binary-buffer-payload-using-node-red

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!