Answers for "Post Request Example in Java"

0

Post Request Example in Java

@BeforeAll
    public static void init(){
        RestAssured.baseURI = "http://........." ;
        RestAssured.port = 8000 ;
        RestAssured.basePath = "/api" ;
    }
String myBodyData = "{\n" +
                "  \"name\"  : \"Adam\",\n" +
                "  \"gender\": \"Male\",\n" +
                "  \"phone\": 6234567890\n" +
                "}" ;

        System.out.println("myBodyData = " + myBodyData);

        given()
                .contentType( ContentType.JSON )
                .body(myBodyData)
                .log().all().
        when()
                .post("/spartans").
        then()
                .log().all()
                .statusCode( is(201) )
                .contentType(ContentType.JSON)
                .body("success", is ("A Spartan is Born!"))
                .body("data.name", is ("Adam"))
        ;
Posted by: Guest on May-30-2021

Code answers related to "Post Request Example in Java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language