For some reason I need to call a GET method API and pass json request body for it. I really couldn't find an example for it. I wonder if it is even supported using feign. How can I do that using feign?
Asked
Active
Viewed 1.9k times
2 Answers
6
Yes, Feign supports it. You can do the same as with POST requests:
@FeignClient(name = "clientName", url = "http://localhost:8888")
public interface SampleFeignClient {
@GetMapping("/remote")
String test(@RequestBody SampleRequestBody sampleRequestBody);
}
But be aware: a lot of servers ignore body or even refuse that kind of "non-standard" requests completely (GET or HEAD with request bodies).

amseager
- 5,795
- 4
- 24
- 47
6
According to the documentation the correct way to do it would be to use the @SpringQueryMap
annotation.
@FeignClient(name = "clientName", url = "http://localhost:8888")
public interface SampleFeignClient {
@GetMapping("/remote")
String test(@SpringQueryMap SampleRequestBody sampleRequestBody);
}
You can find more information here

chaitanya guruprasad
- 641
- 7
- 18