Testing A Post API Using Restassured
Purpose of POST
POST requests create new resources on the server, typically sending a JSON body containing the new resource's data.
Example
given()
.contentType("application/json")
.body("{ \"name\": \"Asha\", \"job\": \"QA\" }")
.when()
.post("https://reqres.in/api/users")
.then()
.statusCode(201)
.body("name", equalTo("Asha"));
What to Verify
Confirm the status code (commonly 201 Created), that the response echoes back the submitted data correctly, and that a new resource identifier is returned.
Ready to master real-world software testing?
Learn manual and automation testing hands-on with mentor-led sessions.
.png)