I'm using Activiti and Eclipse. Now I want to upload my process to web UI through restful API. Follow the document, I test it successfully in Postman.
My request has a basic auth: enter image description here
And this is body with a file to upload: enter image description here
My problem is I don't know how to do that request in Java code, I write some code following some Stack's post but it doesn't work.
HttpClient httpClient = HttpClientBuilder.create().build();
HttpPost request = new HttpPost("http://localhost:8080/activiti-rest/service/repository/deployments");
request.addHeader("content-type","multipart/form-data");
//convert credentials to base64
byte[] credentials = Base64.encodeBase64(("kermit:kermit").getBytes(StandardCharsets.UTF_8));
request.setHeader("Authorization", "Basic " + new String(credentials, StandardCharsets.UTF_8));
request.setEntity(new FileEntity(new File("C:/Users/ISC-HaoNMN/Desktop/ActivitiProcess.bar")));
httpClient.execute(request);
Can someone give me a sample code. Thank you!