简体   繁体   中英

Orion Context Broker Post ":" character

When I make a POST call to the Orion Context Broker and the entity "type": "geo:json" contains the ":" character I obtain:

{"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"
 },

}'\

Apparently this is not a problem in the MongoDB of Orion. I am able to insert the "type": "geo:json" in the MongoDB. Probably some validation before making the post call, cause the problem. Any contribution will be very appreciated.

I think the problem is that your request has two errors.

First, you cannot use a JSON object as entity type. Entity types must be strings. Thus you have to use:

"type": "Traffic"

Second, the GeoJSON object you are using for location value is incorrect. Point uses a single coordinate in coordinates , not a list.

In sum, the following request will work:

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"
 }                                      
}'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM