Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] in GET "/v2/entities/<id>/attrs/<attr_name>/value" with several Accept header #1635

Closed
iariasleon opened this issue Dec 17, 2015 · 3 comments
Assignees
Milestone

Comments

@iariasleon
Copy link
Contributor

in Attribute Value --> By Entity ID --> Get attribute value
GET /v2/entities/<id>/attrs/<attr_name>/value

  • If Accept: application/json and the attribute value is number or string or boolean or null returns a json response as {"value":56.000000} or {"value": "34"} or {"value":true} instead of an error message, ex:
HTTP code: 406 Not Acceptable
{
    "error": "NotAcceptable",
    "description": "no defined yet"
} 
  • If Accept: text/plain always returns a string, also in number, boolean or null values
@fgalan
Copy link
Member

fgalan commented Dec 17, 2015

Actually, this is already taken into account in issue #1259 part 6. However, let's hold this issue if you want, to make more explicit the need of checking this after #1259 completion from a QA perspective.

@raconte
Copy link
Contributor

raconte commented Jan 22, 2016

Create an entity (POST)

(curl localhost:1026/v2/entities -s -S --header Content-Type:application/json -d @- | python -mjson.tool)<< EOF
{
  "type": "Room",
  "id": "Room1",
  "temperature": {
    "value": 23.4
  },
  "humidity": {
    "value": 78
  },
  "location": {
    "value": "41.3763726, 2.1864475",
    "type": "geo:point",
    "metadata": {
      "crs": {
        "value": "WGS84"
      }
    }
  }
}

Created succesfully

Get attribute value by entity ID

In case of Accept: text/plain

curl localhost:1026/v2/entities/Room1/attrs/temperature/value  --header 'Accept: text/plain'

Returns the number 23.4000

Get attribute value by entity ID

In case of Accept: application/json

curl localhost:1026/v2/entities/Room1/attrs/temperature/value  --header 'Accept: application/json'

Response is:

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

Solved

@iariasleon
Copy link
Contributor Author

LGTM

Status: 406: Not Acceptable
{
"error": "NotAcceptable"
"description": "accepted MIME types: text/plain"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants