2

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!

Tomato
  • 759
  • 2
  • 14
  • 26
  • please add some error stacktrace as well as full Rest-api code.. to identify the exact problem – Vikrant Kashyap Dec 13 '18 at 08:04
  • Sorry but it don't have anything in my error log for me to know what error is going on. Because of that so I just want a sample code to re-write :( – Tomato Dec 13 '18 at 08:12
  • go through this https://stackoverflow.com/questions/1378920/how-can-i-make-a-multipart-form-data-post-request-using-java – Monis Majeed Dec 13 '18 at 08:23

0 Answers0