After a looooooooooooong time of searching and trying different things I already found the solution (that works for me). It uses Okhttp library so you will need to import it.
If anyone else need it, there it is:
public void importJUnitTestExecRequest() {
OkHttpClient client = new OkHttpClient();
String reportFile = GlobalVariable.reportFolder + "\\JUnit_Report.xml";
File file = new File(reportFile);
String url = GlobalVariable.importTestExecJUnitEndpoint+"?testExecKey="+GlobalVariable.testExecKey;
//Form request body that will be a multipart
RequestBody requestBody = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("file", file.getName(), RequestBody.create(MediaType.parse("text/xml"), file))
.build();
//Form the actual request adding necessary headers
Request request = new Request.Builder()
.url(url)
.post(requestBody)
.addHeader("Content-Type", GlobalVariable.contentTypeMultipart)
.build();
Response response = null;
try {
response = client.newCall(request).execute();
println("************ IMPORT TEST EXECUTION RESULTS RAW RESPONSE ************");
println("Response status: " + response);
println("********************************************************************");
if (response.isSuccessful()){
String responseBody = response.body().string();
println("************ IMPORT TEST EXECUTION RESULTS RESPONSE BODY ************");
println(responseBody);
println("*********************************************************************");
} else {
throw new IOException("Unexpected HTTP code " + response);
}
} catch (IOException e) {
e.printStackTrace();
}
}
I've opened a ticket to support because with the built in functionality in Katalon, it is currently (or I don't know how to do it) not possible.