RESTAssured POST request

1,374 views
Skip to first unread message

vivek

unread,
Feb 24, 2012, 5:16:17 AM2/24/12
to REST assured
hi,

I am starting to use rest assured as it is very simple and suits my
requirement. I am trying to send a POST request, which has an XML as
the request body. I am unaware of how to do it using rest assured. Can
u provide a sample code snippet which does a POST service and has an
XML in the request body.

i have the xml saved in my system within the project as request.xml ,
can i send the same as part of the request body?

Frédéric Camblor

unread,
Feb 24, 2012, 5:30:16 AM2/24/12
to rest-a...@googlegroups.com
Hi vivek,


body() can take a byte[] (or a String) => this way, you can pass whatever format you want as a simple content (you just have to read it by yourself first)

Cheers,

Frédéric Camblor  
Bordeaux JUG Board member
Jenkins community member & plugin commiter

Johan Haleby

unread,
Feb 24, 2012, 5:30:37 AM2/24/12
to rest-a...@googlegroups.com
It depends. If you want to "upload" the file to the server you should use multi-part file uploading support (see usage guide) otherwise you must read the XML from the file and put it in the request body:

given().body(xml).when().post(..);

/Johan
Reply all
Reply to author
Forward
0 new messages