使用`Fiware-Service:tourguide`标头时,无法将属性值作为JSON获取

时间:2016-05-25 13:25:17

标签: fiware-orion

我们正在测试如何在Tourguide应用程序(https://github.com/Fiware/tutorials.TourGuide-App)中获取属性值,但它似乎无法正常工作。

如果我们执行:

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

我们得到了

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

但如果我们执行:

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

我们得到预期值:

Elizalde

我们尝试使用以下方法强制执行JSON响应:

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

但我们得到了同样的错误:

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

我们已经进行了一些额外的测试。

我们按照https://github.com/telefonicaid/fiware-orion/blob/develop/doc/apiary/v2/fiware-ngsiv2-reference.apib#L922

中的描述创建Bcn-Welt实体

如果我们执行:

curl -v <cb_host>:<cb_port>/v2/Entities/Bcn-Welt/attrs/humidity/value 我们得到了预期的价值。

但是,如果我们使用Fiware-service: tourguide标头创建实体并再次执行请求(使用Fiware-Service: tourguide header):

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

我们得到:

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

有关使用的上下文代理版本的信息

{ "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 个答案:

答案 0 :(得分:1)

NGSIv2 specification开始,在GET属性值操作(GET /v2/entities/entityId/attrs/attrName/value):

  

如果响应有效负载MIME类型是application / json:

     
      
  • ...
  •   
  • 如果属性值是字符串,数字,null或布尔值,则HTTP错误&#34; 406不可接受:接受的MIME类型:text / plain&#34;归还。
  •   

所以行为似乎是预期的。

附注:您不应在网址中使用/v2/Entities/...,而应在NGSIv2规范中定义/v2/entities(小写&#39; E&#39;)。