1
votes

In a case that I would like to update value and metadata, if I don't set the attribute type in the request body, it will update attribute type to "none" and I'll lose the information.

I'm not sure if it's should happen. This endpoint doesn't allow PATCH requests.

e.g.:

I have an attribute called temperature, its type is 'cassius'.

PUT http://localhost:1026/v2/entities/Room1/attrs/temperature?type=Room

Body:

{
"value": 20,
"metadata":{"han":"solo"}
}

Representation with cURL:

curl -X PUT -H "Fiware-Service: teste_1" -H "Content-Type: application/json" -d '{
"value": 20, "metadata":{"han":"solo"}
}' "http://localhost:1026/v2/entities/Room1/attrs/temperature?type=Room"

After this request, the original attribute type is gone because it has been set to "none", since it's not present on request body was set to none.

PS: I'd not tested with text/plain content type.

Orion Context Broker Info:

{
  "orion" : {
  "version" : "1.2.0-next",
  "uptime" : "9 d, 17 h, 27 m, 37 s",
  "git_hash" : "c1a224db08086751f05d471a8b52c0eaec15f3a5",
  "compile_time" : "Thu Aug 4 09:04:12 BRT 2016",
  "compiled_by" : "root"
}

}

1

1 Answers

1
votes

if you do a PUT you are replacing the whole attribute and type is reset to "none" by the implementation.

Try to update only the value and type will remain.

http://localhost:1026/v2/entities/Room1/attrs/temperature/value