发布到 orion 让我 "Attribute must be a JSON object"
Posting to orion gets me to "Attribute must be a JSON object"
我正在将此发送给 Orion:
curl --location --request POST 'http://xx.xx.xx.xx:1026/ngsi-ld/v1/entities/' \
--header 'link: <https://smartdatamodels.org/context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
--header 'Content-Type: application/json' \
--data-raw '{
"id": "urn:ngsi-ld:Device:01",
"type": "Device",
"description": "L9A",
"category": {
"value": ["sensor"]
},
"serialNumber": {
"value": "38479144"
},
"controlledProperty": {
"value": ["Water Supply"]
},
"owner": {
"value": ["Me"]
},
"location": {
"type": "Point",
"coordinates": [20.200416, 30.261837]
}
}'
我明白了:
错误 400:错误请求
{
"type": "https://uri.etsi.org/ngsi-ld/errors/BadRequestData",
"title": "Attribute must be a JSON object",
"detail": "description"
}
我通过 json 对象验证,它通过了。我做错了什么?
仔细查看您的错误消息,尤其是:
detail": "description"
那是不是 JSON 对象的属性的名称:
"description": "L9A"
如果将其更改为:
"description": {
"type": "Property",
"value": "L9A"
}
那部分应该没问题。
但是,您的所有属性似乎都缺少 type
成员。
你需要将 "type": "Property"
添加到所有这些,除了“位置”是 GeoProperty
:
"location": {
"type": "GeoProperty",
"value": {
"type": "Point",
"coordinates": [20.200416, 30.261837]
}
}
也许花点时间阅读 NGSI-LD 规范?
https://www.etsi.org/deliver/etsi_gs/CIM/001_099/009/01.04.02_60/gs_CIM009v010402p.pdf
我正在将此发送给 Orion:
curl --location --request POST 'http://xx.xx.xx.xx:1026/ngsi-ld/v1/entities/' \
--header 'link: <https://smartdatamodels.org/context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
--header 'Content-Type: application/json' \
--data-raw '{
"id": "urn:ngsi-ld:Device:01",
"type": "Device",
"description": "L9A",
"category": {
"value": ["sensor"]
},
"serialNumber": {
"value": "38479144"
},
"controlledProperty": {
"value": ["Water Supply"]
},
"owner": {
"value": ["Me"]
},
"location": {
"type": "Point",
"coordinates": [20.200416, 30.261837]
}
}'
我明白了:
错误 400:错误请求
{
"type": "https://uri.etsi.org/ngsi-ld/errors/BadRequestData",
"title": "Attribute must be a JSON object",
"detail": "description"
}
我通过 json 对象验证,它通过了。我做错了什么?
仔细查看您的错误消息,尤其是:
detail": "description"
那是不是 JSON 对象的属性的名称:
"description": "L9A"
如果将其更改为:
"description": {
"type": "Property",
"value": "L9A"
}
那部分应该没问题。
但是,您的所有属性似乎都缺少 type
成员。
你需要将 "type": "Property"
添加到所有这些,除了“位置”是 GeoProperty
:
"location": {
"type": "GeoProperty",
"value": {
"type": "Point",
"coordinates": [20.200416, 30.261837]
}
}
也许花点时间阅读 NGSI-LD 规范? https://www.etsi.org/deliver/etsi_gs/CIM/001_099/009/01.04.02_60/gs_CIM009v010402p.pdf