[英]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,我想将其作为 http 链接键值值发送
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
.看起来 Feign 无法正确转换MultiValueMap
中的值。 DO you know how I can fix this issue?你知道我该如何解决这个问题吗?
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,?>尝试将 u MultiValueMap<String, String> 更改为 Map<String,?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.