Tim
unread,Sep 30, 2011, 4:55:43 AM9/30/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to REST assured
Hello,
I'm trying to test a pdf-upload and when I compare the request from a
browser with the request from RestAssured, there seems to be a
difference which causes the test to fail (because the server can not
read the pdf).
Test code:
----------------
File f = new File(WORK_DIR + PDF_TEMPLATE);
Response response = given().
header("Accept", "text/html,application/xhtml+xml,application/
xml;q=0.9,*/*;q=0.8").
header("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7").
formParam("naam", naam).
formParam("tags", tags).
multiPart("pdf", f, "application/pdf").
when().post(BASE_URL + "rest/template/");
The RestAssured Request:
---------------------------------------
--XlMPMT1ptKPwSohV1ALhMDbyFCM6lBE-qSGFA
Content-Disposition: form-data; name="pdf";
filename="template_fietspadinspecties.pdf"
%PDF-1.7
%����
...
The corresponding browser request:
---------------------------------------------------
-----------------------------326212769225293
Content-Disposition: form-data; name="pdf";
filename="template_fietspadinspecties.pdf"
Content-Type: application/pdf
%PDF-1.7
%����
...
---> As you can see, the browser also sends "Content-Type: application/
pdf", RestAssured does not, although I specified it in
multiPart("pdf", f, "application/pdf").
Doest anyone knows how to fix this?
Thx,
Tim