'Send MultiValueMap params as http link key-value values
I have this MultiValueMap with params which I would like to send as http link key-value values
MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
map.add("entityId", "123456");
map.add("amount", "123456");
Feign Client:
@FeignClient(name = "Staging", url = "https://test.com")
public interface Client {
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
SaleResponse performSaleTransaction(@QueryMap MultiValueMap<String, String> params);
}
But I get exception:
feign.FeignException$BadRequest: [400 Bad Request] during [POST] to [https://test.com] [Client#performSaleTransaction(String,MultiValueMap)]: [{"result":{"code":"200.300.404","description":"invalid or missing parameter","parameterErrors":[{"name":"entityId","value":null,"message":"invalid or missing parameter"}]},"buildNumber":"......","timestamp":"2021-05-23 12:31:52+0000","ndc":"......"}]
at feign.FeignException.clientErrorStatus(FeignException.java:195)
Looks like Feign cannot convert properly the values from the MultiValueMap
. DO you know how I can fix this issue?
Solution 1:[1]
I found in sources
if (MAP_STRING_WILDCARD.equals(bodyType)) {
data = (Map<String, Object>) object;
MAP_STRING_WILDCARD is Map<String,?>
try to change u MultiValueMap<String, String> to Map<String,?>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Alexandr |