这是一个需要携带参数在form url上的请求,正常调用方式是这样的
响应:
在Feign中,应该怎么调用呢??
定义OpenFeignClient接口
@FeignClient(value = "client-service", url = "http://127.0.0.1/api")
public interface ClientDemo {@Headers({"Content-Type: application/x-www-form-urlencoded;charset=UTF-8"})@PostMappingString getInfo(@RequestBody LinkedMultiValueMap<String, Object> params);}
然后构建 LinkedMultiValueMap即可调用访问
// TODO 发送feign调用LinkedMultiValueMap<String, Object> params = new LinkedMultiValueMap<>();params.add("api", "auto");params.add("fun", "abc");params.add("userid", "123456789");params.add("id","123456789");params.add("statue", "1");params.add("sign", "0000000");String result = clientDemo.getInfo(params);
调用成功