I'm using Rest Assured to test my API. My client endpoint (/client
) return a JSON like:
{
"id":1,
"nombre":"Juan Loquesea",
"email":"[email protected]",
"idProvincia":7,
"fechaRegistro":"06/04/2016 10:00:00"
}
And this is my test code:
public void test() {
get("/client").then().assertThat()
.statusCode(200)
.body("id", equalTo(1));
}
But I get this error:
java.lang.IllegalArgumentException: Invalid JSON expression:
Script1.groovy: 1: expecting EOF, found ':' @ line 1, column 31.
http://172.'20'.'20'.'20:8080'.id
^
What is happening?
Solved! I had this code in my test class:
@BeforeClass
public static void init() {
RestAssured.rootPath = "http:172.20.20.20:8080"
}
I have removed it and it is working now.