code: public Api getActionResult(String action, String params, TokenResult token,
        Object pFormData, String format) throws Exception {
      String text = this.getActionResultText(action, params, token, pFormData,
          format);
      Api api = null;
      if ("xml".equals(format)) {
        if (debug) {
          // convert the xml to a more readable format
          String xmlDebug = text.replace(">", ">\n");
          LOGGER.log(Level.INFO, xmlDebug);
        }
        if (text.startsWith("<?xml version"))
          api = fromXML(text);
        else {
          LOGGER.log(Level.SEVERE, text);
          throw new Exception("invalid xml:" + text);
        }
      } else if ("json".equals(format)) {
        if (debug) {
          LOGGER.log(Level.INFO,
              text.substring(0, Math.min(240, text.length() - 1)));
        }
        if (gson == null)
          gson = new Gson();
        api = gson.fromJson(text, Api.class);
        api.setRawJson(text);
      } else {
        throw new IllegalStateException("unknown format " + format);
      }
      return api;
    }
docs: get the result for the given action and params
  
  @param action
  @param params
  @param token
  (may be null)
  @param formData
  (may be null)
  @format - the format to use e.g. json or xml
  @return the API result for the action
  @throws Exception