1
votes

I have a request that looks like this :

http://localhost:8080/car/bmw;color=red

that returns the model of car and it's color as json data. If I do the request without specifying color it will default to color green.

And the Java code:

String resourcePath = "http://localhost:8080/"
String carModel= "bmw"
String color = "red"

 RestAssuredResponseImpl response =
 (RestAssuredResponseImpl) given().
     when().get(resourcePath + "car/" + carModel + ";color=" + color );

When I copy/paste the url into browser it returns the json as expected , but when I try to get it with rest-assured I get a 404 not found error. I've tried sending the request with param("color",color) but it just ignores the parameters and returns the default json.

1
Shouldn't the semicolon (;) in the URL be a question mark (?) to indicate the start of the request parameters? - pczeus
Nope , this are matrix parameters. - Karudi
Also I found this answer stackoverflow.com/questions/31744172/… , but I can't figure out how to build a request like this . - Karudi
Also github.com/jayway/rest-assured/issues/417 , rest-assured currently does not support matrix parameters. - Karudi
Question is answered here : stackoverflow.com/questions/35387879/… - Karudi

1 Answers

1
votes

It seems that matrix-parameters are not supported yet. Today (January, 2020) this is still an open feature request for RestAssured: https://github.com/rest-assured/rest-assured/issues/417

The recommended workaround is to switch-off URL-encoding.

given().urlEncodingEnabled(false)
    .when()
    .get("http://localhost:8080/car/bmw;color=red");