Claudia Claudia - 1 year ago 179
Java Question

How to write Restfuse HttpTest with MULTIPART_FORM_DATA?

I can not figure out, how to write the Rest Test. Please help me out.

I have a RestService:

public Response insertDataInDB(@FormDataParam("inputfile")
MultipartFormDataInput inputfile) {

do Stuff

The Service works, i tested it with Chromes Rest Console.

Request URI:


Content Type:


Attachements Files:


Parameter Key:


How does the Rest Test look? I tried this

But i can't quite figure it out, where to put the parameter key etc.

@HttpTest(method = Method.POST, path = "persDB/rest/r/insertDataInDB", content = "{}", type = MediaType.MULTIPART_FORM_DATA, file = "inputfile.xlsx")
public void insertDataInDB() {
do Stuff

and i'm getting a

2014-02-04 16:01:30,825 [http-/] SEVERE org.jboss.resteasy.core.SynchronousDispatcher - Failed executing POST r/insertDataInDB: org.jboss.resteasy.spi.ReaderException: Unable to get boundary for multipart

Answer Source

Take a look at this answer and full explanation here

You need to add this header to your request:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download