1
votes

We are testing how to get attributes values in the Tourguide application ( https://github.com/Fiware/tutorials.TourGuide-App) and it does not seem to work properly.

If we perform:

curl -v <cb_host>:<cb_port>/v2/Entities/0115206c51f60b48b77e4c937835795c33bb953f/attrs/name/value -s -S --header 'Fiware-Service: tourguide'

we get

{"error":"NotAcceptable","description":"accepted MIME types: text/plain"}

But if we perform:

curl -v <cb_host>:<cb_port>/v2/Entities/0115206c51f60b48b77e4c937835795c33bb953f/attrs/name/value -s -S --header 'Fiware-Service: tourguide' --header 'Accept: text/plain'

we get the expected value:

Elizalde

We tried to force the JSON response using:

curl -v <cb_host>:<cb_port>/v2/Entities/0115206c51f60b48b77e4c937835795c33bb953f/attrs/name/value -s -S --header 'Fiware-Service: tourguide' --header 'Accept: application/json'

but we get the same error:

{"error":"NotAcceptable","description":"accepted MIME types: text/plain"}

We have performed some additional tests.

We create the Bcn-Welt entity as described in https://github.com/telefonicaid/fiware-orion/blob/develop/doc/apiary/v2/fiware-ngsiv2-reference.apib#L922

If we perform:

curl -v <cb_host>:<cb_port>/v2/Entities/Bcn-Welt/attrs/humidity/value we get the expected value.

But, if we create the entity using the Fiware-service: tourguide header and perform the request again (using the Fiware-Service: tourguide header):

curl -v <cb_host>:<cb_port>/v2/Entities/Bcn-Welt/attrs/humidity/value -s -S --header 'Fiware-Service: tourguide'

we get:

{"error":"NotAcceptable","description":"accepted MIME types: text/plain"}

Information about the context broker version used

{ "orion" : { "version" : "1.1.0-next", "uptime" : "0 d, 2 h, 16 m, 2 s", "git_hash" : "2397fd46be54008409e7b2e4d29e572a2c598f2c", "compile_time" : "Tue May 24 10:38:00 UTC 2016", "compiled_by" : "root", "compiled_in" : "838a42ae8431" } }

1

1 Answers

1
votes

From NGSIv2 specification, at GET attribute value operation (GET /v2/entities/entityId/attrs/attrName/value):

If response payload MIME type is application/json:

  • ...
  • If attribute value is a string, number, null or boolean, a HTTP error "406 Not Acceptable: accepted MIME types: text/plain" is returned.

So it seems that behaviour is as expected.

Side-note: you shouldn't use /v2/Entities/... in the URLs, but /v2/entities (lowercase 'E') as defined in the NGSIv2 specification.