public  static JsonElement executeRequest(WebRequest request) throws Exception {
        WebResponse response = request.getResponse();
        int responseCode = response.getStatusCode();
        String responseBody = response.getContent();

        if (responseCode != HttpStatus.SC_OK && responseCode != HttpStatus.SC_CREATED && responseCode != HttpStatus.SC_ACCEPTED) {
            throw new RuntimeException(String.format("%d:%s", responseCode, responseBody));
        }

        return new JsonParser().parse(new JsonReader(new StringReader(responseBody)));
    }
Executes a web request and throws an exception if the status code is incorrect.

@param request
@return
@throws Exception
ambari-funtest/src/test/java/org/apache/ambari/funtest/server/utils/RestApiUtils.java