Support multipart uploading for PUT requests. (spring-mock-mvc)

781 views
Skip to first unread message

Bill Grant

unread,
Jan 12, 2016, 11:43:34 PM1/12/16
to REST assured
It's my understanding that multi-part PUT requests are supported as of 1.6, but it seems they aren't for the RestAssuredMockMvc module.

Currently multi-part file data uploading only works for POST
java.lang.IllegalArgumentException: Currently multi-part file data uploading only works for POST

Is support for this feature coming in the future?

Johan Haleby

unread,
Jan 13, 2016, 2:28:41 AM1/13/16
to rest-a...@googlegroups.com
Unfortunately I can't remember why this is not supported. Do you know if it's support by vanilla MockMvc? If so I cannot see a reason for why we shouldn't get it working in RestAssuredMockMvc. Please add it as an issue as well.

Regards,
/Johan

--
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...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thomas Melville

unread,
Apr 2, 2019, 7:39:50 AM4/2/19
to REST assured
Hi Bill/Johan,

Was an issue ever created for this?
I think it's now possible with vanilla MockMvc, according to this https://stackoverflow.com/questions/37305114/how-to-make-unit-test-multipart-with-a-put-request-using-spring-mvc-and-spock

BR
Thomas
To unsubscribe from this group and stop receiving emails from it, send an email to rest-a...@googlegroups.com.

Johan Haleby

unread,
Apr 2, 2019, 7:53:40 AM4/2/19
to rest-a...@googlegroups.com
Thanks for the info!

To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.

Mike England

unread,
Feb 20, 2020, 1:11:03 AM2/20/20
to REST assured
It is possible to use the MockMvc work-around (described in the stackoverflow link above) directly using RestAssured. The idea is the same...use a requestPostProcessor to convert the POST into a PUT. 

Example:
RequestPostProcessor requestPostProcessor = request -> {
    request.setMethod("PUT");
    return request;
};

given().postProcessors(requestPostProcessor)
    .contentType(MULTIPART_FORM_DATA_VALUE)
    .multiPart("file", myFile)
    .when().post(myUrl)
    .then().statusCode(SC_OK);
Reply all
Reply to author
Forward
0 new messages