当我对 Orion 上下文代理和实体进行 POST 调用时 "type": "geo:json" 包含我获得的 ":" 字符:
{"error":"InternalError","description":"Database Error (collection: orion-carouge.entities - insert(): { _id: { id: "10_Place_Nations"....
curl -X POST
http://<entityID>:port/v2/entities
-H 'Content-Type: application/json'
-H 'fiware-service:carouge'
-H 'Fiware-ServicePath:/Traffic'
-d '{ "type": {
"value": "Traffic"
},
"dateObserved": {
"value": "2019-05-22T21:26:00"
},
"id": "10_Place_Nations",
"location": {
"value": {
"coordinates": [
[
6.130983321064038,
46.21602766413273
]
],
"type" : "Point"
},
"type": "geo:json"
},
}'
显然,这在Orion的MongoDB中不是问题。我可以在MongoDB中插入"type":"geo:json"。在进行发布调用之前可能进行了一些验证,从而导致问题。 任何贡献将不胜感激。
问题是您的请求有两个错误。
首先,不能将 JSON 对象用作实体类型。实体类型必须是字符串。因此,您必须使用:
"type": "Traffic"
其次,用于location
值的 GeoJSON 对象不正确。点在coordinates
中使用单个坐标,而不是列表。
总之,以下请求将起作用:
curl -X POST
http://localhost:1026/v2/entities
-H 'Content-Type: application/json'
-H 'fiware-service:carouge'
-H 'Fiware-ServicePath:/Traffic'
-d '{ "type": "Traffic",
"dateObserved": {
"value": "2019-05-22T21:26:00"
},
"id": "10_Place_Nations",
"location": {
"value": {
"coordinates": [
6.130983321064038,
46.21602766413273
],
"type" : "Point"
},
"type": "geo:json"
}
}'