我使用orion和导游应用程序中填充的mongodb创建了一个小堆栈。
我不明白为什么更新查询不起作用:(
如果我查询上下文:
curl -s -X GET -H "Accept: text/plain" -H "fiware-service: tourguide" 'http://localhost:1026/v2/entities/0115206c51f60b48b77e4c937835795c33bb953f/attrs/capacity/value'
我正确地得到了值“50”
如果我按照查询示例更新值:
curl -s -v -X PUT -H "Accept: text/plain" -H "fiware-service: tourguide" -H "Content-Type: text/plain" 'http://160.85.2.22:1026/v2/entities/0115206c51f60b48b77e4c937835795c33bb953f/attrs/capacity/value' -d 52
我收到错误“找不到请求的实体。检查类型和ID”
* Trying 160.85.2.22...
* Connected to 160.85.2.22 (160.85.2.22) port 1026 (#0)
> PUT /v2/entities/0115206c51f60b48b77e4c937835795c33bb953f/attrs/capacity/value?type=Restaurant HTTP/1.1
> Host: 160.85.2.22:1026
> User-Agent: curl/7.47.0
> Accept: application/json
> fiware-service: tourguide
> Content-Type: text/plain
> Content-Length: 2
>
} [2 bytes data]
* upload completely sent off: 2 out of 2 bytes
< HTTP/1.1 404 Not Found
< Connection: Keep-Alive
< Content-Length: 95
< Content-Type: application/json
< Fiware-Correlator: 9d2f4164-48f3-11e6-af87-0242ac110004
< Date: Wed, 13 Jul 2016 12:16:23 GMT
<
{ [95 bytes data]
* Connection #0 to host 160.85.2.22 left intact
{
"description": "The requested entity has not been found. Check type and id",
"error": "NotFound"
}
答案 0 :(得分:1)
据我了解,您正在使用FIWARE Tour Guide Application的上下文数据。在该上下文数据中,餐馆实体属于不同的service paths。特别是,每个Resturant属于与其department
属性值对应的服务路径。
因此,请查看0115206c51f60b48b77e4c937835795c33bb953f实体的department
属性(使用Fiware-Service标题:“tourguide”)。如果属性的值是例如“Franchise4”,那么您必须在PUT请求中使用以下服务路径头(注意最初的/
):
-H "fiware-servicepath: /Franchise4"
为什么对属性值的GET请求在没有服务路径头的情况下工作,而属性值上的PUT请求不是?省略标头时,查询请求默认为/#
(表示“任何服务路径”),而create / udpate请求默认为/
(这是根服务路径,与之不匹配) /Franchise4
)。