[英]POST from nodemcu to orion, 411 error but Content-Length exists in headers
[英]Orion Context Broker Post ":" character
当我对 Orion Context Broker 进行 POST 调用并且实体“type”:“geo:json”包含我获得的“:”字符时:
{"error":"InternalError","description":"数据库错误(集合: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 对象不正确。 Point 在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"
}
}'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.