AnsweredAssumed Answered

submit a form data

Question asked by cylia.ami on Nov 29, 2018

hi,

I want to submit  a form data of task, After when I get the form values I find them null.

 

the Code

public void submitForm() throws MalformedURLException, IOException, JSONException {
String request = "{\"taskId\" : \"" + this.idTask + "\",\"properties\" : [{\"id\" : \"id\", \"value\" : \"cylia123\"}, { \"id\" : \"nom\", \"value\" : \"cylia\"},{\"id\" : \"nbr_jour\", \"value\" : \"22\"}]}";

URL url = new URL("http://10.6.99.57:8888/activiti-rest/service/form/form-data");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
String authString = "" + this.Login + ":" + this.pwd + "";
byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
String authStringEnc = new String(authEncBytes);
con.setRequestProperty("Authorization", "Basic " + authStringEnc);
// Set the request method to POST as required from the API
con.setRequestMethod("POST");
// Set the Content-Type to "application/json" as required from the API
con.setRequestProperty("Content-Type", "application/json");
con.setDoOutput(true);
// The book we want to create in JSON format
try (OutputStream os = con.getOutputStream()) {
// The book we want to create in JSON format
System.out.println(" le corps de la requette de  validation est : " + request);
os.write(request.getBytes());
os.flush();
}
}

Outcomes