Node-Red,LoraWan Actility平台 [英] Node-Red, LoraWan Actility plattform

查看:155
本文介绍了Node-Red,LoraWan Actility平台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图学习如何在节点红色中为Actility平台添加http获取请求。现在我只收到错误401,不包括授权持有者。



安装完成如下:





我从平台获得两个代码

  curl -X GET --header'Eccept:application / json'--header'授权:Bearer xxx''https://dx-api.thingpark.com/core/latest/ api / devices?deviceEUI = xx& healthState = ACTIVE& statistics = true& extendedInfo = true'

First是令牌持有者。



第二个是请求网址。

 自由软件网页$ p> 

如何创建能够正确生成答案的流程?



谢谢。



功能设置

解决方案

<$ c $里面的Javascript c> function node是沙箱(在虚拟机中运行),因此你不能使用像require这样的功能。但是,这不是问题 - 您可以在函数 msg.headers 对象中$ c>节点或甚至在更改节点。



您没有向我们显示您注入的数据,但根据 http请求节点信息,您可以将所有这些(可选)字段作为输入传递,这些字段可以成为对Actility系统的请求的一部分:


  msg.url(string)
如果未在节点中配置,则此可选属性设置url
请求。

msg.method(string)
如果未在节点中配置,则此可选属性设置请求的HTTP
方法。必须是GET,PUT,POST,PATCH或DELETE之一。

msg.headers(object)
设置请求的HTTP头。

msg.cookies(object)
如果设置,可用于发送带有请求的cookie。

msg.payload
作为请求正文发送。


假设您要注入要POST的有效负载数据Actility,你可以使用一个简单的函数节点添加你需要的Auth头,它可以做这样的事情:

  msg.method = POST; 
msg.headers = {
授权:Bearer xxx,
Content-Type:application / json
};
返回消息;

或者,假设您将承载凭证字符串作为有效负载传递给函数,并且您有一个固定的有效载荷发送到Actility - 然后你的功能可能是这样的:

  msg.method =POST; 
msg.headers = {
授权:持票人+ msg.payload,
内容类型:application / json
};
msg.payload = {foo:bar};
返回消息;

注意:为了使用这些注入的字段, http请求节点无法先前已将其值定义为节点配置的一部分。


im trying to learn how to add a http get request for the Actility plattform in Node red. For now i only recive an error 401 that the authorization bearer is not included.

Setup is done like this:

I get two codes from the plattform

curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer xxx' 'https://dx-api.thingpark.com/core/latest/api/devices?deviceEUI=xx&healthState=ACTIVE&statistics=true&extendedInfo=true'

First is the token bearer.

second is the request url.

https://dx-api.thingpark.com/core/latest/api/devices?deviceEUI=xxx&healthState=ACTIVE&statistics=true&extendedInfo=true

How can i create a flow that produces the answer correctly?

Thank you.

function setup

解决方案

The Javascript inside a function node is sandboxed (runs in a virtual machine), and so you cannot use some features like "require". However, this is not a problem -- you can add any header information directly to the msg.headers object, either in your function node or even in a change node.

You don't show us what data you are injecting, but according to the http request node info, you can pass all of these (optional) fields as input that can become part of the request to the Actility system:

msg.url (string)
    If not configured in the node, this optional property sets the url
    of the request.

msg.method (string)
    If not configured in the node, this optional property sets the HTTP
    method of the request. Must be one of GET, PUT, POST, PATCH or DELETE.

msg.headers (object)
    Sets the HTTP headers of the request.

msg.cookies (object)
    If set, can be used to send cookies with the request.

msg.payload
    Sent as the body of the request.

Assuming you are injecting the payload data that you want to POST to Actility, you can just add the Auth headers you need using a simple function node that does something like this:

msg.method = "POST";
msg.headers = {
    "Authorization": "Bearer xxx",
    "Content-Type": "application/json"
};
return msg;

Or, let's say you were passing the bearer credential string into the function as the payload, and you have a fixed payload to send to Actility -- then your function could look something like this:

msg.method = "POST";
msg.headers = {
    "Authorization": "Bearer " + msg.payload,
    "Content-Type": "application/json"
};
msg.payload = { "foo": "bar" };
return msg;

Note: in order for these injected fields to be used, the http request node cannot have previously defined their values as part of the node's configuration.

这篇关于Node-Red,LoraWan Actility平台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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