0

I have to get a max value for userId using RestAssured and Gpath syntax. I dont know what i should type in body after then.

I have tried so many ways but it does not work.

@BeforeClass
public void setUp() {
    endpoint = "https://jsonplaceholder.typicode.com/posts/";
}


public static Response getJsonPath(String endpoint) {
    return
            when().
                    get(endpoint).
                    then().
                    statusCode(200).
                    contentType(ContentType.JSON).extract().response();
}


@Test
public void maxUserId() {

    Response response = getJsonPath(endpoint)
            .then()
            .assertThat()
            .body();
}
idzik
  • 1

1 Answers1

0

You can use like this. i tried and i got 10 as max value.

public static void maxUserId() {

    int maxValue = getJsonPath(endpoint).jsonPath().get("userId.max()");
    System.out.println(maxValue);
}
Arun Nair
  • 425
  • 3
  • 11