Search code examples
spring-cloud-netflixnetflix-feignspring-cloud-feign

Spring Cloud Feign: Feign doesn't put parameter into HTTP body when issuing POST request


Here is my Feign interface definition:

@RequestMapping(value = "/group/list", method = RequestMethod.POST)
    List<AdvertGroupVO> list(AdvertGroupVO vo,
                             @RequestParam("page") int page,
                             @RequestParam("size") int size);

Although this is a POST request, but feign still puts page and size into URL instead of request body:

2016-09-03 17:59:39 [DEBUG] o.a.coyote.http11.InternalNioInputBuffer - Received [POST /group/list?page=1&size=8&groupId=6 HTTP/1.1
Accept: */*
User-Agent: Java/1.8.0_45
Host: 10.236.65.24:8080
Connection: keep-alive

]

I cannot figure out why


Solution

  • Parameters annotated with @RequestParam will be added to URL query string regardless of the HTTP method. Only parameter with no annotation will be added to request body and you must customize your own Feign Encoder.