Is there a way to construct Url with query parameters where the value of the query param is not string. For String values of query parameter there are APIs in RestAssured or apache httpClient but I could not find any such API matching my needs.
e.g. Query param is:
Map queryParam = ImmutableMap.of("activityTypeList", Arrays.asList(1,2,3));
For String valued query parameters, I am following the below approach:
public String urlBuilder(String url, Map<String, String> queryParam) throws URISyntaxException{
URIBuilder uriBuilder = new URIBuilder(url);
for(Map.Entry<String, String> entry: queryParam.entrySet()){
uriBuilder.addParameter(entry.getKey(), entry.getValue());
}
return uriBuilder.toString();
}
I understand this can be achieved by:
request.queryParam("activityTypeList", Arrays.asList(1,2,3));
where request
is an object of type RequestSpecification
. I am more interested in the URL construction approach.
A followup question: Is there an API which provides the URL that the RestAssured client hits after URL construction; would be much helpful for logging.
Any lead in RestAssured/httpClient/okHttp would really help.