How do you specify query parameters in a RestAssured request?

How do you specify query parameters in a RestAssured request?

A) queryParam()
B) param()
C) withQuery()
D) addQuery()

Answer:

A) queryParam()

Explanation:

The queryParam() method in RestAssured is used to specify query parameters in an HTTP request. Query parameters are appended to the URL in key-value pairs.

For example:


import static io.restassured.RestAssured.*;

given().
    queryParam("key", "value").
    when().
    get("/api/resource").
    then().
    statusCode(200);

In this example, the queryParam() method adds a query parameter with key “key” and value “value” to the GET request.

Reference links:

https://www.javaguides.net/p/top-java-libraries.html

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top