private Document execute(HttpMethod method) throws ClientException, ApiException {
    try {
      method.setRequestHeader(
          "User-Agent",
          "Java Viddler API Client/" + CLIENTVERSION + " (" + System.getProperty("os.name") + " "
              + System.getProperty("os.version") + "; Java " + System.getProperty("java.vm.version") + "; "
              + System.getProperty("user.language") + ")");
      httpClient.executeMethod(method);
      Header contentTypeHeader = method.getResponseHeader("Content-Type");
      String contentType = contentTypeHeader != null ? contentTypeHeader.getValue() : null;
      if (contentType == null || !contentType.startsWith("text/xml")) {
        throw new ClientException("Invalid API response contentType: " + contentType + ". Should be text/xml.");
      }

      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      DocumentBuilder db;
      try {
        db = dbf.newDocumentBuilder();
        Document doc = db.parse(method.getResponseBodyAsStream());
        if ("error".equals(doc.getFirstChild().getNodeName())) {
          throw new ApiException(unmarshal(doc, Error.class));
        }
        return doc;
      } catch (ParserConfigurationException e) {
        throw new ClientException("There was a problem initializing XML parser", e);
      } catch (SAXException e) {
        throw new ClientException("There was a problem parsing API response", e);
      }
    } catch (HttpException e) {
      throw new ClientException("There was a problem with http request", e);
    } catch (IOException e) {
      throw new ClientException("There was a problem with http request", e);
    }

  }