Fiware httpCustom负载中没有替换
我想在OCB中创建一个httpCustom负载,但没有正确的替换信息。我想我已经测试了所有我知道的方法,但没有结果,有人可以帮助我。这是我的代码:Fiware httpCustom负载中没有替换,fiware,fiware-orion,Fiware,Fiware Orion,我想在OCB中创建一个httpCustom负载,但没有正确的替换信息。我想我已经测试了所有我知道的方法,但没有结果,有人可以帮助我。这是我的代码: "notification": { "httpCustom": { "url": "http://xxxx.xxxx.xxxx:8080/api/v1/telemetry", &quo
"notification": {
"httpCustom": {
"url": "http://xxxx.xxxx.xxxx:8080/api/v1/telemetry",
"payload": "[{ %22temperature%22: %22${id}%22, %22humidity%22: %22${humidity}%22, %22battery%22: %22${battery}%22 }]"
},
"attrs": [
"temperature","humidity","battery"
]
},
当我订阅时没有错误,但是当我在端点测试宏${…}的no replace时,有效负载获取对象信息,但没有值
我有一个测试,将${id}作为有效负载中字段的值写入/发送,而不进行任何替换。用URL编码和%22测试它,但没有成功,我想可能是禁用替换?但我已经检查过了,它的值是假的
这是一个http响应:
{
"method": "POST",
"path": "/",
"query": {},
"headers": {
"x-forwarded-for": "3.124.211.58",
"x-forwarded-proto": "https",
"x-forwarded-port": "443",
"host": "83efe9565d48d8bc8cf298d7786b8042.m.pipedream.net",
"x-amzn-trace-id": "Root=1-5f1bddce-7f2b4277458e77b98c0920d1",
"content-length": "54",
"user-agent": "orion/2.1.0 libcurl/7.29.0",
"fiware-service": "example",
"fiware-servicepath": "/example",
"accept": "application/json",
"content-type": "application/json",
"fiware-correlator": "a7fcfe32-ce47-11ea-9723-0242ac14000a",
"ngsiv2-attrsformat": "custom"
},
"bodyRaw": "[{ \"temperature\": \"\", \"humidity\": \"\", \"battery\": \"\" }]",
"body": [
{
"temperature": "",
"humidity": "",
"battery": ""
}
]
}
猎户座版本:2.1.0,在2.4.0中测试
有什么帮助吗?提前谢谢 我用Orion 2.4.0做了以下测试。Orion数据库在开始测试前为空 首先,创建此订阅:
curl -v localhost:1026/v2/subscriptions -s -S -H 'Content-Type: application/json' -d @- <<EOF
{
"subject": {
"entities": [
{
"id": "Device1",
"type": "Device"
}
]
},
"notification": {
"httpCustom": {
"url": "http://localhost:1027/api/v1/telemetry",
"payload": "[{ %22temperature%22: %22\${id}%22, %22humidity%22: %22\${humidity}%22, %22battery%22: %22\${battery}%22 }]"},
"attrs": [
"temperature","humidity","battery"
]
}
}
EOF
接下来,创建如下实体(触发通知):
这是预期的结果,包括替换
接下来,重新启动侦听过程并以这种方式更新实体(触发新通知):
结论:根据我的测试,猎户座按预期工作
我建议仔细看看上面的步骤,并尝试找出与您的案例相比可能存在的任何差异。请注意订阅创建负载中的
\$
:需要避免在curl
中替换bash vars。也许你也面临着类似的问题?您可以使用GET/v2/subscriptions
或直接在数据库(csubs
collection)中检查订阅情况。一个快速问题。。。您是如何发送请求的?卷曲邮递员?其他的?谢谢我有一个IoTAgent(LoraWan)在OCB上更新我的设备,然后我有一个在crater.db上正常工作的历史订阅,还有另一个订阅(这一个),与thingboards.io集成(这就是我需要手动负载的原因)。我正在测试我的订阅,因为有人把它发送到piperStream.com(requestbin),在那里我看不到宏被替换。我已将OCB更新为2.4.0,但结果相同。感谢您的帮助。我从未想过我必须替换$character,文档示例中没有指定,因此非常感谢您的任命。它现在工作正常。如果你发现一个文件中有错误的例子,请让我知道,这样我们就可以解决它。谢谢自定义有效负载部分at:Orion Context Broker编程手册在谷歌搜索中找到了它:关于at上的自定义有效负载部分,请注意,显示的是httpCustom
fragment的逐字示例,与使用该片段的工具无关(curl或其他)。因此,从我的观点来看,这不是一个错误的例子(或者可能我遗漏了一些东西,在这种情况下,我想请你详细说明一下)。同样适用于引用的Orion Context Broker编程手册
nc -l -p 1027
curl localhost:1026/v2/entities -s -S -H 'Content-Type: application/json' -d @- <<EOF
{
"id": "Device1",
"type": "Device",
"temperature": {
"value": 23,
"type": "Number"
},
"humidity": {
"value": 99,
"type": "Number"
},
"battery": {
"value": 15,
"type": "Number"
}
}
EOF
POST /api/v1/telemetry HTTP/1.1
Host: localhost:1027
User-Agent: orion/2.4.0 libcurl/7.52.1
Fiware-Servicepath: /
Accept: application/json
Content-Length: 65
Content-Type: text/plain; charset=utf-8
Fiware-Correlator: 4ae608b0-d248-11ea-81de-000c29df7908
Ngsiv2-AttrsFormat: custom
[{ "temperature": "Device1", "humidity": "99", "battery": "15" }]
curl localhost:1026/v2/entities/Device1/attrs?options=forcedUpdate -s -S -H 'Content-Type: application/json' -d @- <<EOF
{
"temperature": {
"value": 32,
"type": "Number"
},
"humidity": {
"value": 79,
"type": "Number"
},
"battery": {
"value": 25,
"type": "Number"
}
}
EOF
POST /api/v1/telemetry HTTP/1.1
Host: localhost:1027
User-Agent: orion/2.4.0 libcurl/7.52.1
Fiware-Servicepath: /
Accept: application/json
Content-Length: 65
Content-Type: text/plain; charset=utf-8
Fiware-Correlator: 66278dd8-d248-11ea-822d-000c29df7908
Ngsiv2-AttrsFormat: custom
[{ "temperature": "Device1", "humidity": "79", "battery": "25" }]