• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 50
  • Last Modified:

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

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

0
mozboones
Asked:
mozboones
  • 2
  • 2
1 Solution
 
CEHJCommented:
I'm not sure what the question is. Are you saying you want us to translate that code into Java?
0
 
mozboonesAuthor Commented:
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.
0
 
CEHJCommented:
OK, so if the question is no longer applicable, please accept your last comment to close the question
0
 
mozboonesAuthor Commented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now