JBoss Community

Re: Process Parameters through REST API?

created by Thomas Setiabudi in jBPM - View the full discussion

I though it is the problem with enctype multipart

 

so I altered to this:

 

public String instantiateDemoEvaluation(String address, String username,
   String reason, String processName) {
  String responseString = "";
  List<NameValuePair> formparams = new ArrayList<NameValuePair>();
  formparams.add(new BasicNameValuePair("employee", "thomas"));
  formparams.add(new BasicNameValuePair("reason", "test"));

  HttpPost httpPost = new HttpPost("http://" + "localhost:8888"
    + "/gwt-console-server/rs/form/process/" + "com.sample.evaluation"
    + "/complete");
  InputStreamReader inputStreamReader = null;
  BufferedReader bufferedReader = null;

  try {

 

  
   StringBody strUsername = new StringBody("thomas");
   StringBody strReason = new StringBody("test");
  
   MultipartEntity reqEntity = new MultipartEntity();
   reqEntity.addPart("employee", strUsername);
   reqEntity.addPart("reason", strReason);
  
  
   httpPost.setEntity(reqEntity);
   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;
}



 

but I got the same error as my previous post

Reply to this message by going to Community

Start a new discussion in jBPM at Community