Path parameters are used in
RESTful APIs to identify specific resources. In REST Assured, you can handle path parameters using the
pathParam method.
Example :
import io.restassured.RestAssured;
import io.restassured.response.Response;
public class PathParameterExample {
public static void main(String[] args) {
Response response = RestAssured.given()
.pathParam("userId", 1)
.when()
.get("https://jsonplaceholder.typicode.com/users/{userId}");
System.out.println(response.getBody().asString());
}
}?
In this example, the
pathParam method is used to set the
userId path parameter.