Reputation: 305
I have a nxt request POST with form url encoded using Feign Client
@FeignClient(
url = "${url}", configuration = NxtApi.Configuration.class)
public interface NxtApi {
@PostMapping(value = "nxt", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
String new(
@RequestParam String requestType, @RequestBody Map<String, ?> payload);
class Configuration {
@Bean
Encoder feignFormEncoder(ObjectFactory<HttpMessageConverters> converters) {
return new SpringFormEncoder(new SpringEncoder(converters));
}
@Bean
Logger.Level feignLoggerLevel() {
return Logger.Level.FULL;
}
}
}
I want to send the same key with two values
Map<String, Object> param = new HashMap<>();
param.put("filter", valueOne);
param.put("filter", valueTwo);
api.new("asset",param);
I need something like that
filter=valueOne&filter=valueTwo
But it's being sent like this (Request response in the log)
filter=[valueOne,valueTwo]
Thanks for any help.
Upvotes: 1
Views: 1531
Reputation: 156
You will have to use a List of String values instead of a Map.
@PostMapping(value = "nxt", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
String new(@RequestParam String requestType, @RequestParam("filter") List<String> filter, @RequestBody Map<String, ?> payload);
as I found it here: Spring Cloud Feign Client @RequestParam with List parameter creates a wrong request
Upvotes: 2