We found an issue while testing the tourguide application https://github.com/Fiware/tutorials.TourGuide-App.
If we try to get an attribute value from a restaurant:
curl <cb_host>:<cb_port>/v2/Entities/Elizalde/attrs/aggregateRating/value -s -S --header 'Content-Type: application/json' --header 'x-auth-token:<token>' --header 'Fiware-service: tourguide'
we get the attribute value as expected:
{"reviewCount":1,"ratingValue":3}
But if we try to update the value following the instructions for update an attribute value http://fiware.github.io/context.Orion/api/v2/:
curl -v -X PUT <cb_host>:<cb_port>/v2/Entities/Elizalde/attrs/aggregateRating/value?Type=Restaurant -s -S --header 'Content-Type: application/json' --header 'x-auth-token:<token>' --header 'Fiware-service: tourguide' -d '{"reviewCount": 1,"ratingValue": 10}'
we get a 404 error.
If we follows the detailed instructions for update an attribute a JSON in the API cookbook http://fiware.github.io/context.Orion/api/v2/cookbook/
curl -v -X PUT <cb_host>:<cb_port>/v2/Entities/Elizalde/attrs/aggregateRating/value -s -S --header 'Content-Type: application/json' --header 'x-auth-token:<token>' --header 'Fiware-service: tourguide' -d '{"value": {"reviewCount": 1,"ratingValue": 10}}'
We also get a 404 error.
Steps to replicate:
- Clone the tourguide repository.
- Deploy the docker containers:
cd fiware-devguide-app/docker/composeanddocker-compose -f docker-compose.yml up - Get token as explained here : https://github.com/Fiware/tutorials.TourGuide-App#how-to-retrieve-an-oauth-token-to-use-the-api
- Perform the specified requests.
Information about orion version:
<orion>
<version>0.28.0</version>
<uptime>0 d, 1 h, 12 m, 25 s</uptime>
<git_hash>aaf8020a5de680b6d7e0c00c70cf425bcc4f39c8</git_hash>
<compile_time>Mon Mar 21 13:20:37 UTC 2016</compile_time>
<compiled_by>root</compiled_by>
<compiled_in>838a42ae8431</compiled_in>
</orion>
Updated
In order to use the last version of Orion CB available at Docker, we have updated the docker-compose of the tourguide application and we get the same errors.
This is the information about the last version:
{
"orion" : {
"version" : "1.0.0-next",
"uptime" : "0 d, 0 h, 8 m, 20 s",
"git_hash" : "9a35f04739a4236711bdf5b48152eaa21c3377b2",
"compile_time" : "Wed Apr 20 11:41:57 UTC 2016",
"compiled_by" : "root",
"compiled_in" : "838a42ae8431"
}
}
We have executed the Context Broker in debug mode, and if we perform:
curl -v -X PUT orion:1026/v2/Entities/Elizalde/attrs/aggregateRating/value?type=Restaurant -s -S --header 'Content-Type: application/json' --header 'x-auth-token:HuUUHhQ6Qh8myI3o3uI2rYeOIK1Ym1' --header 'Fiware-service: tourguide' -d '{"reviewCount": 1,"ratingValue": 10}'
we get this output:
orion_1 | DEBUG@07:33:12 rest.cpp[955]:
orion_1 | DEBUG@07:33:12 rest.cpp[956]: --------------------- Serving request PUT /v2/Entities/Elizalde/attrs/aggregateRating/value -----------------
orion_1 | DEBUG@07:33:12 rest.cpp[274]: HTTP Header: User-Agent: curl/7.35.0
orion_1 | DEBUG@07:33:12 rest.cpp[274]: HTTP Header: Host: orion:1026
orion_1 | DEBUG@07:33:12 rest.cpp[274]: HTTP Header: Accept: */*
orion_1 | DEBUG@07:33:12 rest.cpp[274]: HTTP Header: Content-Type: application/json
orion_1 | DEBUG@07:33:12 rest.cpp[274]: HTTP Header: x-auth-token: HuUUHhQ6Qh8myI3o3uI2rYeOIK1Ym1
orion_1 | DEBUG@07:33:12 rest.cpp[274]: HTTP Header: Fiware-service: tourguide
orion_1 | DEBUG@07:33:12 rest.cpp[274]: HTTP Header: Content-Length: 36
orion_1 | DEBUG@07:33:12 sem.cpp[276]: transactionIdSet taking the 'trans' semaphore for 'changing the transaction id'
orion_1 | DEBUG@07:33:12 sem.cpp[297]: transactionIdSet has the 'trans' semaphore
orion_1 | DEBUG@07:33:12 sem.cpp[373]: transactionIdSet gives the 'trans' semaphore for 'changing the transaction id'
orion_1 | INFO@07:33:12 logMsg.h[1805]: Starting transaction from 172.17.0.1:48854/v2/Entities/Elizalde/attrs/aggregateRating/value
orion_1 | DEBUG@07:33:12 rest.cpp[225]: URI parameter: type: Restaurant
orion_1 | DEBUG@07:33:12 rest.cpp[1059]: Got 36 of payload of 36 bytes
orion_1 | DEBUG@07:33:12 ContextAttribute.cpp[259]: Creating a ContextAttribute 1
orion_1 | DEBUG@07:33:12 ContextAttribute.cpp[259]: Creating a ContextAttribute 1
orion_1 | DEBUG@07:33:12 ContextAttribute.cpp[259]: Creating a ContextAttribute 1
orion_1 | DEBUG@07:33:12 RestService.cpp[411]: Parsing payload for URL '/v2/Entities/Elizalde/attrs/aggregateRating/value', method 'PUT', service vector index: 12
orion_1 | DEBUG@07:33:12 RestService.cpp[413]: Parsing payload '{"reviewCount": 1,"ratingValue": 10}'
orion_1 | DEBUG@07:33:12 RestService.cpp[101]: parsing data for service 'EntityAttributeValueRequest'. Method: 'PUT'
orion_1 | DEBUG@07:33:12 RestService.cpp[102]: outFormat: JSON
orion_1 | DEBUG@07:33:12 CompoundValueNode.cpp[59]: Created EMPTY compound node at 0x7f0754001720
orion_1 | DEBUG@07:33:12 CompoundValueNode.cpp[59]: Created EMPTY compound node at 0x7f0754001800
orion_1 | DEBUG@07:33:12 CompoundValueNode.cpp[59]: Created EMPTY compound node at 0x7f0754001910
orion_1 | DEBUG@07:33:12 RestService.cpp[127]: result: 'OK'
orion_1 | DEBUG@07:33:12 RestService.cpp[128]: outFormat: JSON
orion_1 | DEBUG@07:33:12 RestService.cpp[415]: payloadParse returns 'OK'
orion_1 | DEBUG@07:33:12 RestService.cpp[437]: Treating service PUT /v2/Entities/Elizalde/attrs/aggregateRating/value
orion_1 | DEBUG@07:33:12 RestService.cpp[483]: tenant: 'tourguide'
orion_1 | DEBUG@07:33:12 ContextAttribute.cpp[309]: Creating a ContextAttribute: compoundValueP at 0x7f0754001720 for attribute 'aggregateRating' at 0x7f0754001c20
orion_1 | DEBUG@07:33:12 sem.cpp[147]: mongoUpdateContext taking the 'req' semaphore for 'ngsi10 update request'
orion_1 | DEBUG@07:33:12 sem.cpp[168]: mongoUpdateContext has the 'req' semaphore
orion_1 | DEBUG@07:33:12 MongoGlobal.cpp[684]: Service Path JSON string: '{ $in: [ null, /^\/$/ ] }'
orion_1 | DEBUG@07:33:12 MongoGlobal.cpp[420]: database name composed: 'orion-tourguide'
orion_1 | DEBUG@07:33:12 connectionOperations.cpp[203]: count() in 'orion-tourguide.entities' collection: '{ _id.id: "Elizalde", _id.type: "Restaurant", _id.servicePath: { $in: [ null, /^/$/ ] } }'
orion_1 | INFO@07:33:12 connectionOperations.cpp[210]: Database Operation Successful (count: { _id.id: "Elizalde", _id.type: "Restaurant", _id.servicePath: { $in: [ null, /^/$/ ] } })
orion_1 | DEBUG@07:33:12 MongoGlobal.cpp[420]: database name composed: 'orion-tourguide'
orion_1 | DEBUG@07:33:12 connectionOperations.cpp[65]: query() in 'orion-tourguide.entities' collection: '{ _id.id: "Elizalde", _id.type: "Restaurant", _id.servicePath: { $in: [ null, /^/$/ ] } }'
orion_1 | INFO@07:33:12 connectionOperations.cpp[79]: Database Operation Successful (query: { _id.id: "Elizalde", _id.type: "Restaurant", _id.servicePath: { $in: [ null, /^/$/ ] } })
orion_1 | DEBUG@07:33:12 MongoCommonUpdate.cpp[2891]: Docs found: 0
orion_1 | DEBUG@07:33:12 ContextAttribute.cpp[342]: Creating a string ContextAttribute 'aggregateRating':'none':'', setting its compound to NULL
orion_1 | DEBUG@07:33:12 MongoGlobal.cpp[1514]: Entity discovery: {id: Elizalde, type: Restaurant}
orion_1 | DEBUG@07:33:12 MongoGlobal.cpp[1526]: Attribute discovery: 'aggregateRating'
orion_1 | DEBUG@07:33:12 MongoGlobal.cpp[684]: Service Path JSON string: '{ $in: [ null, /^\/$/ ] }'
orion_1 | DEBUG@07:33:12 MongoGlobal.cpp[1566]: Offset: 0, Limit: 0, Details: false
orion_1 | DEBUG@07:33:12 MongoGlobal.cpp[420]: database name composed: 'orion-tourguide'
orion_1 | DEBUG@07:33:12 connectionOperations.cpp[134]: query() in 'orion-tourguide.registrations' collection limit=0, offset=0: '{ query: { $or: [ { contextRegistration.entities: { $in: [ { id: "Elizalde", type: "Restaurant" }, { type: "Restaurant", id: "Elizalde" } ] } }, { contextRegistration.entities.id: { $in: [] } } ], expiration: { $gt: 1461223992 }, contextRegistration.attrs.name: { $in: [ "aggregateRating" ] }, servicePath: { $in: [ null, /^/$/ ] } }, orderby: { _id: 1 } }'
orion_1 | INFO@07:33:12 connectionOperations.cpp[153]: Database Operation Successful (query: { query: { $or: [ { contextRegistration.entities: { $in: [ { id: "Elizalde", type: "Restaurant" }, { type: "Restaurant", id: "Elizalde" } ] } }, { contextRegistration.entities.id: { $in: [] } } ], expiration: { $gt: 1461223992 }, contextRegistration.attrs.name: { $in: [ "aggregateRating" ] }, servicePath: { $in: [ null, /^/$/ ] } }, orderby: { _id: 1 } })
orion_1 | DEBUG@07:33:12 MongoGlobal.cpp[1514]: Entity discovery: {id: Elizalde, type: Restaurant}
orion_1 | DEBUG@07:33:12 MongoGlobal.cpp[684]: Service Path JSON string: '{ $in: [ null, /^\/$/ ] }'
orion_1 | DEBUG@07:33:12 MongoGlobal.cpp[1566]: Offset: 0, Limit: 0, Details: false
orion_1 | DEBUG@07:33:12 MongoGlobal.cpp[420]: database name composed: 'orion-tourguide'
orion_1 | DEBUG@07:33:12 connectionOperations.cpp[134]: query() in 'orion-tourguide.registrations' collection limit=0, offset=0: '{ query: { $or: [ { contextRegistration.entities: { $in: [ { id: "Elizalde", type: "Restaurant" }, { type: "Restaurant", id: "Elizalde" } ] } }, { contextRegistration.entities.id: { $in: [] } } ], expiration: { $gt: 1461223992 }, servicePath: { $in: [ null, /^/$/ ] } }, orderby: { _id: 1 } }'
orion_1 | INFO@07:33:12 connectionOperations.cpp[153]: Database Operation Successful (query: { query: { $or: [ { contextRegistration.entities: { $in: [ { id: "Elizalde", type: "Restaurant" }, { type: "Restaurant", id: "Elizalde" } ] } }, { contextRegistration.entities.id: { $in: [] } } ], expiration: { $gt: 1461223992 }, servicePath: { $in: [ null, /^/$/ ] } }, orderby: { _id: 1 } })
orion_1 | DEBUG@07:33:12 sem.cpp[353]: mongoUpdateContext gives the 'req' semaphore for 'ngsi10 update request'
orion_1 | DEBUG@07:33:12 CompoundValueNode.cpp[228]: Destroying node 0x7f0754001720: name: 'TOP', path '/' at 0x7f0754001720 (with 2 children)
orion_1 | DEBUG@07:33:12 CompoundValueNode.cpp[234]: Deleting child 0, at 0x7f0754001800
orion_1 | DEBUG@07:33:12 CompoundValueNode.cpp[228]: Destroying node 0x7f0754001800: name: 'reviewCount', path '/reviewCount' at 0x7f0754001800 (with 0 children)
orion_1 | DEBUG@07:33:12 CompoundValueNode.cpp[234]: Deleting child 1, at 0x7f0754001910
orion_1 | DEBUG@07:33:12 CompoundValueNode.cpp[228]: Destroying node 0x7f0754001910: name: 'ratingValue', path '/ratingValue' at 0x7f0754001910 (with 0 children)
orion_1 | DEBUG@07:33:12 restReply.cpp[67]: Response 76: responding with 0 bytes, Status Code 404
orion_1 | DEBUG@07:33:12 restReply.cpp[68]: Response payload: ''
orion_1 | DEBUG@07:33:12 UpdateContextResponse.cpp[77]: destroyed
orion_1 | DEBUG@07:33:12 RegisterContextResponse.cpp[56]: destroyed
orion_1 | INFO@07:33:12 logMsg.h[1889]: Transaction ended