given()
It is used in building the DSL expression request with any additional information like headers, params, message body, authentication, etc., before making any HTTP
Request like POST
, GET
, PUT
, DELETE
using given()
method.
Example 1:
RestAssured.given()
.header("header1","value1")
.header("header2", "value2")
.param("param1","paramValue")
.body(body)
.post(url);
In the example above, before sending the POST
request, headers(…), params(…) and body(…) are added to the request builder.
Example 2:
RestAssured.given()
.get(url);
In this example, no extra information is added to the request builder before making a GET
request.
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy