I have simple form with few text fields and one file upload. I can easily fill the form and submit it without attachment thriugh REST API. How do I attach the file to this task?
For filling text fields IA m calling :
http:/localhost:8080/flowable-task/process-api/form/form-data
and for attachment I am using :
http://admin:test@localhost:8080/flowable-task/process-api/form/form-data
I am tying in this way:
LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
FileSystemResource value = new FileSystemResource(new File(fileTouploadFullPath));
map.add(“file”, value);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
headers.set(“Authorization”, "Basic " + base64ClientCredentials);
HttpEntity<LinkedMultiValueMap<String, Object>> requestEntity = new HttpEntity<>(map, headers);
RestTemplate restTemplate = new RestTemplate();
ResponseEntity resposne = restTemplate.exchange(“http://localhost:8080/flowable-task/runtime/tasks/"+taskId+"/attachments”, HttpMethod.POST, requestEntity, String.class);
System.out.println(resposne.getStatusCode()+" "+resposne.getBody());
I am getting Response Status 302 FOUND with empty body. In the background process and task is created with no attachment