Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

REST API returns an application/yaml response #65

Open
BastienL opened this issue May 3, 2017 · 0 comments
Open

REST API returns an application/yaml response #65

BastienL opened this issue May 3, 2017 · 0 comments

Comments

@BastienL
Copy link

BastienL commented May 3, 2017

Not a big issue, but when the text starts with "---", the REST API responds with a yaml instead of a JSON:

curl -XPOST 'localhost:9200/_langdetect?pretty' -d '---This is a test' -i
HTTP/1.1 200 OK
Content-Type: application/yaml
Content-Length: 90

---
profile: "/langdetect/"
languages:
- language: "en"
  probability: 0.9999972283490304

You got to set the Content-Type to application/json to make it return a JSON response:

curl -XPOST 'localhost:9200/_langdetect?pretty' -d '---This is a test' -i -H "Content-Type: application/json"
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 122

{
  "profile" : "/langdetect/",
  "languages" : [ {
    "language" : "en",
    "probability" : 0.9999972283490304
  } ]
}

Maybe that should be mentioned in the documentation that setting the appropriate Content-Type is recommended?

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

No branches or pull requests

1 participant