I am currently facing the following issue with a Java program.
I am trying to upload a file I downloaded from an external server (file type can be different for every execution) to a IBM RTC (or Jazz) server through REST call.
The REST endpoint I am sending the first request (i.e.: the file upload to the central repository) is as the following:
https://jazz.host.com:1234/ccm/service/com.ibm.team.workitem.service.internal.rest.IAttachmentRestService/?projectId=<TEAM_AREA_ID>&multiple=true&category=<CATEGORY_ID>
And this step works, uploading the file to the central repo. What it is not working is the fact that when the attachment name contains some kind of characters (i.e.: £, ù, °, ...) those are changed into the character ?.
I am using Apache HttpClient with a CloseableHttpClient, preparing the HttpEntity to be sent as follows:
java.io.File currentAttachmentFile = utils.getFileFromPath(attachmentPath);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.addBinaryBody("upfile", currentAttachmentFile, ContentType.MULTIPART_FORM_DATA, currentAttachmentFile.getName());
return builder.build();
But even sepcifying the withCharset(StandardCharsets.UTF8)
to ContentType.MULTIPART_FORM_DATA
does not do the trick, the file name stile contains the ? character (while I expect it to be something like: 'file_name 1!==£$%&^+ù°#@'.png').
I took a look around for other suggestions but neither those found here and here are working for the file name. Moreover, specifying the Content-Type
to the POST call I am sending causes a failure with the message 'Invalid POST request message' returned by RTC, so this can't be an option.
Through PostMan, the upload with the same file to the same endpoint works so I suppose there is something I am missing when creating the entity to send to RTC.
Does anyone know how to solve this?
Best regards,
Alberto