In REST Assured, query parameters can be added to a request using the queryParam method, which allows you to specify key-value pairs that will be appended to the URL.
Example :
import io.restassured.RestAssured;
import io.restassured.response.Response;
public class QueryParamExample {
public static void main(String[] args) {
Response response = RestAssured.given()
.queryParam("param1", "value1")
.queryParam("param2", "value2")
.when()
.get("https://api.example.com/resource");
System.out.println(response.getBody().asString());
}
}
?
In this example, the
queryParam
method is used to add two query parameters to the request.