Using rest-sure, we can easily execute GET, POST, and other methods. In the example below, we send POST to an API that returns a JSON response.
@Test public void reserveARide() { given(). header("Authorization", "abcdefgh-123456"). param("rideId", "gffgr-3423-gsdgh"). param("guestCount", 2). when(). post("http://someWebsite/reserveRide"). then(). contentType(ContentType.JSON). body("result.message", equalTo("success")); }
But I need to create a POST request with a complex XML body. Body example:
<?xml version="1.0" encoding="UTF-8"?> <request protocol="3.0" version="xxx" session="xxx"> <info1 param1="xxx" version="xxx" size="xxx" notes="xxx"/> <info2 param1="xxx" version="xxx" size="xxx" notes="xxx"/> </request>
How can i do this? Thank you in advance
source share