No signature of method: org.apache.http.entity.mime.MultipartEntityBuilder.setMimeSubtype() is applicable for argument types: (java.lang.String) values: [form-data]

855 views
Skip to first unread message

Ghulam Ghaus

unread,
Apr 24, 2018, 4:33:41 AM4/24/18
to REST assured
Hi Team, 

I am struggling to write a scenario to upload file (xx.zip) to the server using Rest URI.

Sample code that I have written as bellow:

 final Response response = given().baseUri(DEFAULT_BASE_URL).log().all().config(config).contentType(MediaType.MULTIPART_FORM_DATA)
                .accept(MediaType.APPLICATION_JSON)
                .headers(<header>).multiPart(new MultiPartSpecBuilder(<InputStreamOfZipfile))
                        .fileName(fileName).controlName(<control name>).mimeType("form-data").build())
                .when().post(url).then().extract().response(); 

and I also tried with this way but not luck:
return given().contentType(MediaType.MULTIPART_FORM_DATA).accept(MediaType.APPLICATION_JSON).headers(HEADERS)
    .multiPart("file", fileName, InputStreamOfZipfile).multiPart("filename", fileName).when().post(url);

in both the above implementation I am getting same error as :  groovy.lang.MissingMethodException: No signature of method: org.apache.http.entity.mime.MultipartEntityBuilder.setMimeSubtype() is applicable for argument types: (java.lang.String) values: [form-data]

I am using following artifacts in my project:

rest-assured: 3.1.0
httpmime: 4.5.1
httpclient: 4.5.3
httpcore: 4.4.9

I am struggling from last few weeks, I am unable to understand the issue here. Please help me and unblock me from this issue.

Thank you in Advance! 

Exception Stack trace :
groovy.lang.MissingMethodException: No signature of method: org.apache.http.entity.mime.MultipartEntityBuilder.setMimeSubtype() is applicable for argument types: (java.lang.String) values: [form-data]
at io.restassured.internal.multipart.RestAssuredMultiPartEntity.<init>(RestAssuredMultiPartEntity.groovy:50)
at io.restassured.internal.RequestSpecificationImpl$_registerRestAssuredEncoders_closure24.doCall(RequestSpecificationImpl.groovy:1490)
at io.restassured.internal.http.HTTPBuilder$RequestConfigDelegate.setBody(HTTPBuilder.java:1113)
at io.restassured.internal.http.HTTPBuilder$RequestConfigDelegate.setPropertiesFromMap(HTTPBuilder.java:1025)
at io.restassured.internal.http.HTTPBuilder$post$2.call(Unknown Source)
at io.restassured.internal.RequestSpecificationImpl.sendRequest(RequestSpecificationImpl.groovy:1271)
at io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)
at io.restassured.internal.filter.SendRequestFilter.filter(SendRequestFilter.groovy:30)
at io.restassured.filter.Filter$filter$0.call(Unknown Source)
at io.restassured.filter.Filter$filter.call(Unknown Source)
at io.restassured.internal.filter.FilterContextImpl.next(FilterContextImpl.groovy:72)
at io.restassured.filter.time.TimingFilter.filter(TimingFilter.java:56)
at io.restassured.filter.Filter$filter.call(Unknown Source)
at io.restassured.filter.Filter$filter.call(Unknown Source)
at io.restassured.internal.filter.FilterContextImpl.next(FilterContextImpl.groovy:72)
at io.restassured.filter.log.RequestLoggingFilter.filter(RequestLoggingFilter.java:124)
at io.restassured.filter.Filter$filter.call(Unknown Source)
at io.restassured.internal.filter.FilterContextImpl.next(FilterContextImpl.groovy:72)
at io.restassured.filter.FilterContext$next.call(Unknown Source)
at io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1732)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)
at io.restassured.internal.RequestSpecificationImpl.applyPathParamsAndSendRequest(RequestSpecificationImpl.groovy:1738)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at io.restassured.internal.RequestSpecificationImpl.invokeMethod(RequestSpecificationImpl.groovy)
at io.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy:174)
at io.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy)


Regards,
Ghulam

Ghulam Ghaus

unread,
Apr 25, 2018, 1:22:33 AM4/25/18
to REST assured
Hi, 
Please help... I am about to pull my hair :( 

Johan Haleby

unread,
Apr 25, 2018, 2:39:32 AM4/25/18
to rest-a...@googlegroups.com
It sounds like a bug. Perhaps you could help out and fix it?

--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ghulam Ghaus

unread,
Apr 30, 2018, 2:17:57 AM4/30/18
to REST assured
Hi Johan,

Thanks Johan for your response. It will be great if you indicate where could be possible bug?
I will fill happy if I can do some thing here.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.

Johan Haleby

unread,
May 2, 2018, 2:12:03 AM5/2/18
to rest-a...@googlegroups.com
The only place I can find in the code the calls "setMimeSubtype" is in the RestAssuredMultiPartEntity class.

Regards,
/Johan

Ghulam Ghaus

unread,
May 9, 2018, 4:46:52 AM5/9/18
to REST assured
Hi,

Got the issue and its resolved :) 

I was deploying my tests in jboss by packing in war file. but JBOSS already comes up with old version of httpcore, httpclient and httpmime in jboss module. So whenever I test was executing, that was executing old class from jboss module. 
To fix this issue I change the latest version of httpcomponents in jboss module.

Regards,
Ghulam

Johan Haleby

unread,
May 9, 2018, 7:19:28 AM5/9/18
to rest-a...@googlegroups.com
Ah! Glad you got it working and thanks for sharing.
Reply all
Reply to author
Forward
0 new messages