Explain how to set headers in a request.

Headers in REST Assured are used to pass additional information with an HTTP request or response. To set headers, use the header or headers methods.

Example :

import io.restassured.RestAssured;
import io.restassured.response.Response;
public class RestAssuredExample {
    public static void main(String[] args) {
        Response response = RestAssured.given()
            .header("Content-Type", "application/json")
            .header("Authorization", "Bearer your_token_here")
            .get("https://api.example.com/data");
        System.out.println(response.getStatusCode());
    }
}?

In this example, the header method is used to set the “Content-Type” and “Authorization” headers.