Я пытаюсь сделать вызов REST с параметром запроса, в котором содержится &
.Я могу сделать этот звонок через почтальона, и он работает.URL-адрес https://dev.apiwh.adidas.com/cpm/taxonomy/tags?filter=category-label eq "Body+%26+Mind"
Проблема в коде Java.
String param = "category-label eq \"" + name + "\"";;
[...]
String url = "https://dev.apiwh.adidas.com/cpm/taxonomy/tags";
// Query parameters
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(url)
// Add query parameter
.queryParam("filter", "category-label eq \"" + name + "\"");
URI uri = builder.buildAndExpand().toUri();
HttpEntity<?> entity = new HttpEntity<>(headers);
HttpEntity<String> response = restTemplate.exchange(
uri,
HttpMethod.GET,
entity,
String.class);
Исключение:
URI: https://dev.apiwh.adidas.com/cpm/taxonomy/tags
https://dev.apiwh.adidas.com/cpm/taxonomy/tags?filter=category-label%20eq%20%22Body%20&%20Mind%22
{"exception":"MethodArgumentTypeMismatchException","error":400,"message":"Invalid filter string. Valid filter: 'category-label eq \"value\"' or 'uuid eq \"value\"', 'collection-id eq \"value\"'or 'uuid in (\"value1\",\"value2\")'. \\, \", <, >, tabs and newlines are not allowed.","timestamp":"2019-02-27T09:06:05.203Z","status":"BAD_REQUEST"}
Я попытался указать URL-адрес в виде строки https://dev.apiwh.adidas.com/cpm/taxonomy/tags?filter=category-label eq "Body+%26+Mind"
Все еще существует ошибка на стороне сервера, что Body %26 Mind
недопустимо.