Sean Roberts created AMBARI-9016:
------------------------------------

             Summary: 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


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



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to