Put Request Example in Java

Example: Put Request Example in Java

@BeforeAll
    public static void init(){

        RestAssured.baseURI = "........." ;
        RestAssured.port = 8000 ;
        RestAssured.basePath = "/api" ;
}
@DisplayName("Update exsiting Data")
    @Test
    public void updateSpartan(){

        String updatedBody = "{\n" +
                "        \"id\": 809,\n" +
                "        \"name\": \"Wonder Woman\",\n" +
                "        \"gender\": \"Female\",\n" +
                "        \"phone\": 1234567890\n" +
                "       }" ;

        given()
                .contentType(ContentType.JSON)
                .body(updatedBody)
                .log().all().
        when()
                .put("/spartans/{id}",809).
        then()
                .log().all()
                .statusCode(204) ;

Tags:

Java Example