我尝试使用IoT Agent UL2.0发送测量值。
首先,我按如下方式创建了一个设备:
POST /iot/devices HTTP/1.1
Host: localhost:4061
Fiware-Service: Empresa1
Fiware-ServicePath: /empresa1
Content-Type: application/json
Cache-Control: no-cache
{
"devices": [
{
"device_id": "A6",
"entity_name": "A6",
"entity_type": "E6",
"attributes": [
{ "object_id": "a", "name": "aaa", "type": "text" },
{ "object_id": "b", "name": "bbb", "type": "text" },
{ "object_id": "c", "name": "ccc", "type": "text" }
]
}
]
}
然后我尝试按如下方式发送测量结果:
POST /iot/d?i=A6&k=A6&d=a|7|b|7|c|7 HTTP/1.1
Host: localhost:7896
Fiware-Service: Empresa1
Fiware-ServicePath: /empresa1
Content-Type: text/plain
Cache-Control: no-cache
但我收到以下错误:
{
"name": "DEVICE_GROUP_NOT_FOUND",
"message": "Couldn\t find device group"
}
device group
是什么?
谢谢!
答案 0 :(得分:2)
我想出了如何解决它。
我刚刚在config.defaultTransport
中将HTTP
更改为config.js
,并使用TEF
作为apikey。
向Orion有效发送措施的请求如下:
POST /iot/d?i=A6&k=TEF&d=a|7|b|7|c|7 HTTP/1.1
Host: localhost:7896
Fiware-Service: Empresa1
Fiware-ServicePath: /empresa1
Content-Type: text/plain
Cache-Control: no-cache
我希望这有助于某人。
答案 1 :(得分:1)
要小心,您需要配置一个服务,以便您可以使用自己的API KEY,这可以通过发出这样的HTTP请求来完成
POST http://130.206.80.40:5371/iot/services Headers: { 'Content-Type': 'application/json', 'X-Auth-Token' : '[TOKEN]', 'Fiware-Service': 'openiot', 'Fiware-ServicePath': '/' } Payload: { "services": [ { "apikey": "4jggokgpepnvsb2uv4s40d59ov", "cbroker": "http://0.0.0.0:1026", "entity_type": "thing", "resource": "/iot/d" } ] }
答案 2 :(得分:0)
之前来自 jose-manuel-cantera 的回答是正确的。此外,请注意 resource
字段应以斜杠 /
开头。我遇到了和你一样的问题,请看这张票 https://github.com/telefonicaid/iotagent-ul/issues/459。