In my RestAssured test I have:
String customerId = "1234";
given().queryParam("customerId=" + customerId)
.spec(customerApi).auth().oauth2(token)
.when().log().ifValidationFails()
.get("/api/v1/customers/latest")
.then()
.assertThat()
.statusCode(201);
...where I need to pass a query param with an =
char.
This comes out encoded as follows:
https://customer-api.com/api/v1/customers/latest?customerId%3D1234
What is the cleanest way of resolving this?
You are passing both parameter name and value as the parameter name to RestAssured which then gets escaped.
Just pass the actual value of the parameter as the second argument of queryParam(String, Object...)
. The library will take care of the escaping of parameter name or value if necessary.
.queryParam("customerId", customerId)
This should result in the following:
https://customer-api.com/api/v1/customers/latest?customerId=1234