I am trying to create a test to validate the response of a JSON Post is as expected.
I am trying to test the POST of a JSON message body to a URL which is turn then sends a text message and if successful it sends a response that it was successful again in JSON format.
My test is as follows
public void simpleTest() {
String myJson = "{\"phoneNumber\":\"353837986524\", \"messageContent\":\"test\"}";
given()
.port(31111) // port number
.header("Content-Type", "application/json")
.body(myJson)
.when()
.post("/testenvironment/text/send")
.then().assertThat()
.body("message", equalTo("{\"resultMessage\":\"Message accepted\"}"));
}
But seem to be getting this exception
java.lang.IllegalStateException: You can either send form parameters OR body content in POST, not both!
And I'm not sure what the issue is?