posting multipart form data

744 views
Skip to first unread message

rundmd

unread,
Feb 29, 2016, 11:08:26 AM2/29/16
to REST assured
I'm having trouble trying to figure out how to make a post for multipart form data.  The API I'm testing is using multipart form data to make a video post, but the video isn't in a separate file. Instead, it's include in the json text value of the form parameter. I'm able to make the post using Postman and the content-type in the request header looks like:

multipart/form-data; boundary=----WebKitFormBoundary3WdcWC39srUwHOIg

and the request payload looks like:

    1. ------WebKitFormBoundary3WdcWC39srUwHOIg Content-Disposition: form-data; name="jsonpayload" { "videos": [{ "remote_url": "https://s3.amazonaws.com/somevideo/video.mp4" }], "text": "groups", "author": { "alias": "tester", "token": "14561678011" }, "groups": ["custom"] ,"tags":["tagged"]} ------WebKitFormBoundary3WdcWC39srUwHOIg--
I've tried the following without success:

given()

    .log().all()

    .contentType("multipart/form-data")

    .config(RestAssured.config().encoderConfig(encoderConfig().encodeContentTypeAs("multipart/form-data", ContentType.TEXT)))

    .formParam("jsonpayload", data)

    .post(url)


Any suggestions?


Thanks

Name

?client=bilbo
response.html

Johan Haleby

unread,
Mar 1, 2016, 2:24:08 AM3/1/16
to rest-a...@googlegroups.com
You should be able to supply a JSON document to the "multiPart" method, for example:

given().multiPart("controlName", jsonAsString, "application/json"). ..

For more advanced use cases refer to the com.jayway.restassured.builder.MultiPartSpecBuilder.

--
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.

Reply all
Reply to author
Forward
0 new messages