[ https://issues.apache.org/jira/browse/AMBARI-9016?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sean Roberts updated AMBARI-9016: --------------------------------- Description: The blueprints API, when taking & responding with json, is only accepting Content-Type:application/x-www-form-urlencode and responds with Content-Type:text/plain. For example, the 1st block below sends the json as application/json but fails. While the 2nd block sends "application/x-www-form-urlencoded" and succeeds. Also note that the 2nd response comes back as "text/plain" even though the data is json. {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} {code} $ curl -v -u admin -H x-requested-by:useless http://localhost:8080/api/v1/stacks/HDP/versions/2.4/recommendations -d @temp.json $ cat temp.json | ambari_httpie -vvv POST $ambari_api/stacks/HDP/versions/2.2/recommendations POST /api/v1/stacks/HDP/versions/2.2/recommendations HTTP/1.1 Accept: application/json Accept-Encoding: gzip, deflate Authorization: Basic YWRtaW46YWRtaW4= Content-Length: 187 Content-Type: application/json; charset=utf-8 Cookie: AMBARISESSIONID=17qljv0e8tnn83fk6fyc7qkt2 Host: localhost:8080 User-Agent: HTTPie/0.8.0 X-Requested-By: ambari { "hosts": [ "sandbox.hortonworks.com" ], "recommend": "configurations", "services": [ "HDFS", "MAPREDUCE2", "TEZ", "YARN" ] } HTTP/1.1 406 Not Acceptable Content-Length: 50 Content-Type: text/plain;charset=ISO-8859-1 Server: Jetty(7.6.7.v20120910) { "status": 406, "message": "Not Acceptable" } {code} {code} $ cat temp.json | ambari_httpie -vvv -f POST ${ambari_api}/stacks/HDP/versions/2.2/recommendations POST /api/v1/stacks/HDP/versions/2.2/recommendations HTTP/1.1 Accept: */* Accept-Encoding: gzip, deflate Authorization: Basic YWRtaW46YWRtaW4= Content-Length: 187 Content-Type: application/x-www-form-urlencoded; charset=utf-8 Cookie: AMBARISESSIONID=17qljv0e8tnn83fk6fyc7qkt2 Host: localhost:8080 User-Agent: HTTPie/0.8.0 X-Requested-By: ambari { "hosts": [ "sandbox.hortonworks.com" ], "recommend": "configurations", "services": [ "HDFS", "MAPREDUCE2", "TEZ", "YARN" ] } HTTP/1.1 200 OK Content-Length: 1768 Content-Type: text/plain Server: Jetty(7.6.7.v20120910) { "resources" : "SNIPPED-REST-OF-RESPONSE" } {code} was: The blueprints API, when taking & responding with json, is only accepting Content-Type:application/x-www-form-urlencode and responds with Content-Type:text/plain. For example, the 1st block below sends the json as application/json but fails. While the 2nd block sends "application/x-www-form-urlencoded" and succeeds. Also note that the 2nd response comes back as "text/plain" even though the data is json. {code} $ cat temp.json | ambari_httpie -vvv POST $ambari_api/stacks/HDP/versions/2.2/recommendations POST /api/v1/stacks/HDP/versions/2.2/recommendations HTTP/1.1 Accept: application/json Accept-Encoding: gzip, deflate Authorization: Basic YWRtaW46YWRtaW4= Content-Length: 187 Content-Type: application/json; charset=utf-8 Cookie: AMBARISESSIONID=17qljv0e8tnn83fk6fyc7qkt2 Host: localhost:8080 User-Agent: HTTPie/0.8.0 X-Requested-By: ambari { "hosts": [ "sandbox.hortonworks.com" ], "recommend": "configurations", "services": [ "HDFS", "MAPREDUCE2", "TEZ", "YARN" ] } HTTP/1.1 406 Not Acceptable Content-Length: 50 Content-Type: text/plain;charset=ISO-8859-1 Server: Jetty(7.6.7.v20120910) { "status": 406, "message": "Not Acceptable" } {code} {code} $ cat temp.json | ambari_httpie -vvv -f POST ${ambari_api}/stacks/HDP/versions/2.2/recommendations POST /api/v1/stacks/HDP/versions/2.2/recommendations HTTP/1.1 Accept: */* Accept-Encoding: gzip, deflate Authorization: Basic YWRtaW46YWRtaW4= Content-Length: 187 Content-Type: application/x-www-form-urlencoded; charset=utf-8 Cookie: AMBARISESSIONID=17qljv0e8tnn83fk6fyc7qkt2 Host: localhost:8080 User-Agent: HTTPie/0.8.0 X-Requested-By: ambari { "hosts": [ "sandbox.hortonworks.com" ], "recommend": "configurations", "services": [ "HDFS", "MAPREDUCE2", "TEZ", "YARN" ] } HTTP/1.1 200 OK Content-Length: 1768 Content-Type: text/plain Server: Jetty(7.6.7.v20120910) { "resources" : "SNIPPED-REST-OF-RESPONSE" } {code} (This is my 1st bug report. Tell me how to be make it better). -- Sean Roberts @seano > API not taking or responding with application/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 > Reporter: Sean Roberts > Priority: Minor > Labels: newbie > > The blueprints API, when taking & responding with json, is only accepting > Content-Type:application/x-www-form-urlencode and responds with > Content-Type:text/plain. > For example, the 1st block below sends the json as application/json but > fails. While the 2nd block sends "application/x-www-form-urlencoded" and > succeeds. Also note that the 2nd response comes back as "text/plain" even > though the data is json. > {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} > {code} > $ curl -v -u admin -H x-requested-by:useless > http://localhost:8080/api/v1/stacks/HDP/versions/2.4/recommendations -d > @temp.json > $ cat temp.json | ambari_httpie -vvv POST > $ambari_api/stacks/HDP/versions/2.2/recommendations > POST /api/v1/stacks/HDP/versions/2.2/recommendations HTTP/1.1 > Accept: application/json > Accept-Encoding: gzip, deflate > Authorization: Basic YWRtaW46YWRtaW4= > Content-Length: 187 > Content-Type: application/json; charset=utf-8 > Cookie: AMBARISESSIONID=17qljv0e8tnn83fk6fyc7qkt2 > Host: localhost:8080 > User-Agent: HTTPie/0.8.0 > X-Requested-By: ambari > { > "hosts": [ > "sandbox.hortonworks.com" > ], > "recommend": "configurations", > "services": [ > "HDFS", > "MAPREDUCE2", > "TEZ", > "YARN" > ] > } > HTTP/1.1 406 Not Acceptable > Content-Length: 50 > Content-Type: text/plain;charset=ISO-8859-1 > Server: Jetty(7.6.7.v20120910) > { > "status": 406, > "message": "Not Acceptable" > } > {code} > {code} > $ cat temp.json | ambari_httpie -vvv -f POST > ${ambari_api}/stacks/HDP/versions/2.2/recommendations > POST /api/v1/stacks/HDP/versions/2.2/recommendations HTTP/1.1 > Accept: */* > Accept-Encoding: gzip, deflate > Authorization: Basic YWRtaW46YWRtaW4= > Content-Length: 187 > Content-Type: application/x-www-form-urlencoded; charset=utf-8 > Cookie: AMBARISESSIONID=17qljv0e8tnn83fk6fyc7qkt2 > Host: localhost:8080 > User-Agent: HTTPie/0.8.0 > X-Requested-By: ambari > { > "hosts": [ > "sandbox.hortonworks.com" > ], > "recommend": "configurations", > "services": [ > "HDFS", > "MAPREDUCE2", > "TEZ", > "YARN" > ] > } > HTTP/1.1 200 OK > Content-Length: 1768 > Content-Type: text/plain > Server: Jetty(7.6.7.v20120910) > { > "resources" : "SNIPPED-REST-OF-RESPONSE" > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)