Javax Client.WebTarget: Issue creating The Request Body to support the content-type of multipart/form-data

mozboones used Ask the Experts™
Trying to write a ClientBuilder based method (Java/selenium tool) that handles the following condition: The Request Body for this api should be of type multipart/form-data and it should have a boundary differentiated between file attached to form and form fields

I have done the mutli Part Content in c# but the group needs to be written in Java. Here's the c# code that works for creating the request body. I just having some mental blocks writting the Java HTTP Client version (could not find any realistic samples out there)

Note: I trying to upload an application/msi or application/ms-dos-exec file via the form. Here's my c# code
		 MultipartFormDataContent multiPartContent = new
		 MultipartFormDataContent("----WebKitFormBoundaryliUiaMuaEcUBLr3A"); ByteArrayContent byteArrayContent = new
		 ByteArrayContent(LogoRequest.Content); byteArrayContent.Headers.Add("Content-Type", "image/png"); String
		 FileName = LogoRequest.Name; String ContentDispositionStr = "form-data; name=" + "\"logoImageFile\"" +"; " +
		 "filename=" + FileName; byteArrayContent.Headers.Add("Content-Disposition", ContentDispositionStr);
		 multiPartContent.Add(byteArrayContent); requestMessage.Content = multiPartContent;

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

I'm not sure what the question is. Are you saying you want us to translate that code into Java?
For some odd reason, I could not respond to the experts request for more information.
I was both Chrome and IE and the results were the same - no button or link to respond to the request

So, I canceled my original question.
Top Expert 2016

OK, so if the question is no longer applicable, please accept your last comment to close the question


I did not get a chance to receive a solution. There was an issue with how the solution page that prevented me from responding to the question from the Expert.

I investigating on my end to see if this a setting issue.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial