[
https://issues.apache.org/jira/browse/AMBARI-9016?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sean Roberts updated AMBARI-9016:
---------------------------------
Description:
Ambari responds with a *Content-Type:text/plain* when the content is actually
JSON.
Also, API does not accept the "Content-Type:application/json" even though it
expects the content of the PUT/POSTS to be JSON.
This breaks most any HTTP/Restful client, including the Knox UI proxy.
Here is a GET (with some headers redacted):
{code}
$ curl -i http://localhost:8080/api/v1/clusters
HTTP/1.1 200 OK
Content-Type: text/plain
{
"href" : "http://localhost:8080/api/v1/clusters",
"items" : [
{
"href" : "http://localhost:8080/api/v1/clusters/clustername",
"Clusters" : {
"cluster_name" : "clustername",
"version" : "HDP-2.6"
}
}
]
}
{code}
Attempt to send JSON with Content-Type:application/json fails and it although
it responds with JSON data, it says its "text/plain".
{code}
$ curl -v -u admin\
-H "Content-Type: application/json" -H x-requested-by:useless \
http://localhost:8080/api/v1/stacks/HDP/versions/2.4/recommendations -d
@temp.json
< HTTP/1.1 500 Server Error
< Content-Type: text/plain; charset=ISO-8859-1
{
"status": 500,
"message": "Server Error"
}
{code}
It accepts JSON with Content-Type:text/plain:
{code}
$ curl -v -u admin\
-H "Content-Type: test/plain" -H x-requested-by:useless \
http://localhost:8080/api/v1/stacks/HDP/versions/2.4/recommendations -d
@temp.json
> POST /api/v1/stacks/HDP/versions/2.4/recommendations HTTP/1.1
> Content-Type: test/plain
< HTTP/1.1 200 OK
< Content-Type: text/plain
{
"resources" : [
{
"href" :
"http://localhost:8080/api/v1/stacks/HDP/versions/2.4/recommendations/8",
... snipped the rest of the JSON since it's not needed ...
{code}
This is the file that was sent:
{code}
$ cat temp.json
{
"recommend" : "configurations",
"services" : [
"AMBARI_METRICS","HDFS","HIVE","MAPREDUCE2","PIG","TEZ","YARN","ZOOKEEPER" ],
"hosts" : [
"ip-10-0-1-159.ec2.internal","ip-10-0-1-31.ec2.internal","ip-10-0-1-32.ec2.internal","ip-10-0-1-33.ec2.internal"
]
}
{code}
was:
Ambari responds with a "Content-Type:text/plain" when the content is actually
JSON.
Also, API does not accept the "Content-Type:application/json" even though it
expects the content of the PUT/POSTS to be JSON.
This breaks most any HTTP/Restful client, including the Knox UI proxy.
Here is a GET (with some headers redacted):
{code}
$ curl -i http://localhost:8080/api/v1/clusters
HTTP/1.1 200 OK
Content-Type: text/plain
{
"href" : "http://localhost:8080/api/v1/clusters",
"items" : [
{
"href" : "http://localhost:8080/api/v1/clusters/clustername",
"Clusters" : {
"cluster_name" : "clustername",
"version" : "HDP-2.6"
}
}
]
}
{code}
Attempt to send JSON with Content-Type:application/json fails and it although
it responds with JSON data, it says its "text/plain".
{code}
$ curl -v -u admin\
-H "Content-Type: application/json" -H x-requested-by:useless \
http://localhost:8080/api/v1/stacks/HDP/versions/2.4/recommendations -d
@temp.json
< HTTP/1.1 500 Server Error
< Content-Type: text/plain; charset=ISO-8859-1
{
"status": 500,
"message": "Server Error"
}
{code}
It accepts JSON with Content-Type:text/plain:
{code}
$ curl -v -u admin\
-H "Content-Type: test/plain" -H x-requested-by:useless \
http://localhost:8080/api/v1/stacks/HDP/versions/2.4/recommendations -d
@temp.json
> POST /api/v1/stacks/HDP/versions/2.4/recommendations HTTP/1.1
> Content-Type: test/plain
< HTTP/1.1 200 OK
< Content-Type: text/plain
{
"resources" : [
{
"href" :
"http://localhost:8080/api/v1/stacks/HDP/versions/2.4/recommendations/8",
... snipped the rest of the JSON since it's not needed ...
{code}
This is the file that was sent:
{code}
$ cat temp.json
{
"recommend" : "configurations",
"services" : [
"AMBARI_METRICS","HDFS","HIVE","MAPREDUCE2","PIG","TEZ","YARN","ZOOKEEPER" ],
"hosts" : [
"ip-10-0-1-159.ec2.internal","ip-10-0-1-31.ec2.internal","ip-10-0-1-32.ec2.internal","ip-10-0-1-33.ec2.internal"
]
}
{code}
> Ambari API uses HTTP Header Content-Type:text/plain when the content is JSON.
> -----------------------------------------------------------------------------
>
> Key: AMBARI-9016
> URL: https://issues.apache.org/jira/browse/AMBARI-9016
> Project: Ambari
> Issue Type: Bug
> Components: ambari-server
> Affects Versions: 1.7.0, 2.6.2
> Reporter: Sean Roberts
> Priority: Blocker
> Labels: newbie
>
> Ambari responds with a *Content-Type:text/plain* when the content is actually
> JSON.
> Also, API does not accept the "Content-Type:application/json" even though it
> expects the content of the PUT/POSTS to be JSON.
> This breaks most any HTTP/Restful client, including the Knox UI proxy.
> Here is a GET (with some headers redacted):
> {code}
> $ curl -i http://localhost:8080/api/v1/clusters
> HTTP/1.1 200 OK
> Content-Type: text/plain
> {
> "href" : "http://localhost:8080/api/v1/clusters",
> "items" : [
> {
> "href" : "http://localhost:8080/api/v1/clusters/clustername",
> "Clusters" : {
> "cluster_name" : "clustername",
> "version" : "HDP-2.6"
> }
> }
> ]
> }
> {code}
> Attempt to send JSON with Content-Type:application/json fails and it although
> it responds with JSON data, it says its "text/plain".
> {code}
> $ curl -v -u admin\
> -H "Content-Type: application/json" -H x-requested-by:useless \
> http://localhost:8080/api/v1/stacks/HDP/versions/2.4/recommendations -d
> @temp.json
> < HTTP/1.1 500 Server Error
> < Content-Type: text/plain; charset=ISO-8859-1
> {
> "status": 500,
> "message": "Server Error"
> }
> {code}
> It accepts JSON with Content-Type:text/plain:
> {code}
> $ curl -v -u admin\
> -H "Content-Type: test/plain" -H x-requested-by:useless \
> http://localhost:8080/api/v1/stacks/HDP/versions/2.4/recommendations -d
> @temp.json
> > POST /api/v1/stacks/HDP/versions/2.4/recommendations HTTP/1.1
> > Content-Type: test/plain
> < HTTP/1.1 200 OK
> < Content-Type: text/plain
> {
> "resources" : [
> {
> "href" :
> "http://localhost:8080/api/v1/stacks/HDP/versions/2.4/recommendations/8",
> ... snipped the rest of the JSON since it's not needed ...
> {code}
> This is the file that was sent:
> {code}
> $ cat temp.json
> {
> "recommend" : "configurations",
> "services" : [
> "AMBARI_METRICS","HDFS","HIVE","MAPREDUCE2","PIG","TEZ","YARN","ZOOKEEPER" ],
> "hosts" : [
> "ip-10-0-1-159.ec2.internal","ip-10-0-1-31.ec2.internal","ip-10-0-1-32.ec2.internal","ip-10-0-1-33.ec2.internal"
> ]
> }
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)