将多个实体更新到上下文代理
Upserting multiple entities to context broker
有没有办法在单个 http 请求中将多个实体更新到 Context Broker v2,例如在请求中提交数组?
我有这样的想法:
[POST] /v2/entities/?options=upsert
[
{
id: 'urn:ngsi-ld:xyz:123',
type: 'xyz',
...
},
{
id: 'urn:ngsi-ld:xyz:456',
type: 'xyz',
...
},
...
]
是的,使用 POST /v2/update
和 append
操作类型。例如(取自NGSIv2 API walkthrough的例子):
POST /v2/op/update
{
"actionType": "append",
"entities": [
{
"type": "Room",
"id": "Room3",
"temperature": {
"value": 21.2,
"type": "Float"
},
"pressure": {
"value": 722,
"type": "Integer"
}
},
{
"type": "Room",
"id": "Room4",
"temperature": {
"value": 31.8,
"type": "Float"
},
"pressure": {
"value": 712,
"type": "Integer"
}
}
]
}
这将更新 Room3
和 Room4
实体(如果它们以前存在)或创建它们(如果它们以前不存在)。
有没有办法在单个 http 请求中将多个实体更新到 Context Broker v2,例如在请求中提交数组?
我有这样的想法:
[POST] /v2/entities/?options=upsert
[
{
id: 'urn:ngsi-ld:xyz:123',
type: 'xyz',
...
},
{
id: 'urn:ngsi-ld:xyz:456',
type: 'xyz',
...
},
...
]
是的,使用 POST /v2/update
和 append
操作类型。例如(取自NGSIv2 API walkthrough的例子):
POST /v2/op/update
{
"actionType": "append",
"entities": [
{
"type": "Room",
"id": "Room3",
"temperature": {
"value": 21.2,
"type": "Float"
},
"pressure": {
"value": 722,
"type": "Integer"
}
},
{
"type": "Room",
"id": "Room4",
"temperature": {
"value": 31.8,
"type": "Float"
},
"pressure": {
"value": 712,
"type": "Integer"
}
}
]
}
这将更新 Room3
和 Room4
实体(如果它们以前存在)或创建它们(如果它们以前不存在)。