使用Node-RED发布二进制缓冲区有效负载 [英] Posting binary buffer payload using Node-RED

查看:233
本文介绍了使用Node-RED发布二进制缓冲区有效负载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Node-RED通过POST发送字节数组.我可以使用此模块成功创建缓冲区并将其存储在msg.payload.但是我不知道如何在http请求节点中将其添加为参数.

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.

接收应用程序需要用引号引起来.因此,我在以下网址中使用有效负载:localhost:port/path?var=\"{{payload}}\",但它给出了

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

将http参数转换为参数时出错:无效字符'\'寻找值的开头"

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

如果在请求网址中不带引号使用它:localhost:port/path?var={{payload}}没有任何反应(我可以在另一端看到).

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

由于另一侧的应用程序,我正在使用Protobuf,但我也尝试过创建缓冲区,如此处所述.但是,什么都没有改变.

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.

推荐答案

POST的URL中不应包含参数.数据都应该在体内.

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

您是否需要使msg.payload成为具有与arg名称匹配的键的对象.

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

msg.payload = {
  var = [buffer]
}

您可能必须使用content-type标头,因为默认情况下,我相信Node-RED将发送JSON正文,并且您可能想要application/x-www-form-urlencoded

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

您可以通过添加msg.headers对象来设置标题

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

这篇关于使用Node-RED发布二进制缓冲区有效负载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆