Thomas Setiabudi [https://community.jboss.org/people/thomas.setiabudi] created the discussion
"Re: Process Parameters through REST API?"
To view the discussion, visit: https://community.jboss.org/message/763120#763120
--------------------------------------------------------------
Hi Mai A. S,
Sorry it took so long time to reply, here are the requestGetService and authenticate functions
public String authenticate(String address, String username, String password) {
 String responseString = "";
 List<NameValuePair> formparams = new ArrayList<NameValuePair>();
 formparams.add(new BasicNameValuePair(KEY_USERNAME, username));
 formparams.add(new BasicNameValuePair(KEY_PASSWORD, password));
 HttpPost httpPost = new HttpPost(" http:// http://" + address
   + "/gwt-console-server/rs/process/j_security_check");
 InputStreamReader inputStreamReader = null;
 BufferedReader bufferedReader = null;
 try {
  UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams,
    "UTF-8");// UrlEncodedFormEntity(formparams,
       // "multipart/form-data");
  httpPost.setEntity(entity);
  HttpResponse response = httpClient.execute(httpPost);
  InputStream inputStream = response.getEntity().getContent();
  inputStreamReader = new InputStreamReader(inputStream);
  bufferedReader = new BufferedReader(inputStreamReader);
  StringBuilder stringBuilder = new StringBuilder();
  String line = bufferedReader.readLine();
  while (line != null) {
   stringBuilder.append(line);
   line = bufferedReader.readLine();
  }
  responseString = stringBuilder.toString();
 } catch (Exception e) {
  throw new RuntimeException(e);
 } finally {
  if (inputStreamReader != null) {
   try {
    inputStreamReader.close();
   } catch (Exception e) {
    throw new RuntimeException(e);
   }
  }
  if (bufferedReader != null) {
   try {
    bufferedReader.close();
   } catch (Exception e) {
    throw new RuntimeException(e);
   }
  }
 }
 return responseString;
}
public String requestGetService(String url, Map<String, Object> parameters,
  boolean multipart) {
 String responseString = "";
 MultipartEntity multiPartEntity = new MultipartEntity(
   HttpMultipartMode.BROWSER_COMPATIBLE);
 List<NameValuePair> formparams = new ArrayList<NameValuePair>();
 if (parameters == null) {
  parameters = new HashMap<String, Object>();
 }
 Set<String> keys = parameters.keySet();
 for (Iterator<String> keysIterator = keys.iterator(); keysIterator
   .hasNext();) {
  String keyString = keysIterator.next();
  String value = parameters.get(keyString).toString();
  formparams.add(new BasicNameValuePair(keyString, value));
  if (multipart) {
   try {
    StringBody stringBody = new StringBody(value, "text/plain",
      Charset.forName("UTF-8"));
    multiPartEntity
      .addPart(keyString, (ContentBody) stringBody);
   } catch (Exception e) {
    throw new RuntimeException(e);
   }
  }
 }
 HttpGet httpPost = new HttpGet(url);
 InputStreamReader inputStreamReader = null;
 BufferedReader bufferedReader = null;
 try {
  if (multipart) {
   // httpPost.setEntity(multiPartEntity);
  } else {
   // UrlEncodedFormEntity entity = new UrlEncodedFormEntity(
   // formparams, "UTF-8");// UrlEncodedFormEntity(formparams,
   // "multipart/form-data");
   // httpPost.setEntity(entity);
  }
  HttpResponse response = httpClient.execute(httpPost);
  InputStream inputStream = response.getEntity().getContent();
  inputStreamReader = new InputStreamReader(inputStream);
  bufferedReader = new BufferedReader(inputStreamReader);
  StringBuilder stringBuilder = new StringBuilder();
  String line = bufferedReader.readLine();
  while (line != null) {
   stringBuilder.append(line);
   line = bufferedReader.readLine();
  }
  responseString = stringBuilder.toString();
 } catch (Exception e) {
  throw new RuntimeException(e);
 } finally {
  if (inputStreamReader != null) {
   try {
    inputStreamReader.close();
   } catch (Exception e) {
    throw new RuntimeException(e);
   }
  }
  if (bufferedReader != null) {
   try {
    bufferedReader.close();
   } catch (Exception e) {
    throw new RuntimeException(e);
   }
  }
 }
 return responseString;
}

--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/763120#763120]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]