Conversion des paramètres en chaîne json et affichage de cette chaîne en tant que paramètre de la chaîne de requête.
Map<String, String> parameters = new LinkedHashMap<>();
List<String> productsIsbs = Arrays.asList(request.getProducts())
.stream().map(x -> x.getIsbn()).collect(Collectors.toList());
String params = new Gson().toJson(productsIsbs).replace("\"", "\'");
parameters.put("isbns", params);
GenericApiGatewayRequest apiGatewayRequest;
try {
apiGatewayRequest = new GenericApiGatewayRequestBuilder()
.withHeaders(headers)
.withHttpMethod(HttpMethodName.GET)
.withResourcePath("/bid")
.withParameters(parameters)
.build();
GenericApiGatewayApacheResponse response = client.executeGetWithHttpClient(apiGatewayRequest);
if(response.getHttpResponse().getStatusLine().getStatusCode() == 200) {
String responseJson = response.getBody();
}
} catch (GenericApiGatewayException e) { // exception thrown for any non-2xx response
System.out.println(String.format("Client exception:%s - %s", e.getStatusCode(), e.getMessage()));
e.printStackTrace();
}