rest api automation using java example

Example 1: how to define api details in rest assured automation

We should define all request details
and send it to server in Given,When,Then
methods

Example 2: API/Webservices with RestAssured Library?

import static io.restassured.RestAssured.* ;
URI uri = new URI(" ... / methods(get, post)”)
GET;
Response response =
given().accept(ContentType.JSON).
when().get(URI);
response.
then().assertThat().statusCode(200).
and().assertThat().ContentType(ContentType.JSON);

POST;
Response response =
given().ContentType(ContentType.JSON).with().
accept(ContentType.JSON).and().body(JSONbody).
when().post(URI);
response.
then().assertThat().statusCode(200);

Tags:

Misc Example