Reputation: 1214
The server:
public interface MyClient {
@GetMapping(value = "mypath")
String getStuff(@RequestParam MyDto myDto);
}
@RestController
public class MyClientRestController implements MyClient {
String getStuff(MyDto myDto) {
return myDto.toString();
}
}
The Feign config:
@FeignClient(name = "myserver", url = "${myurl}", path = "/mypath")
public interface MyFeignClient extends MyClient {}
The client call:
String foo = myFeignClient.getStuff(myDto);
Relevant parts of the error stack I get:
org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' is not supported
(...)
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: feign.FeignException$InternalServerError: [500] during [GET] to [http://localhost.xxx:8080/mypath]`
My guess is that Feign or Spring Boot sees a complex object and implies that it's a request body of a POST request.
From a conversation with Gemini (AI), in case of a GET request, Feign and Spring Boot are supposed to convert the DTO into query params, but I can't make it work.
Upvotes: 0
Views: 25
Reputation: 1214
Finally fix it with the use of @SpringQueryMap
, documented here.
This post may be a duplicate of Feign Client GET request, throws "Method Not Allowed: Request method 'POST' not supported" from microservice
Upvotes: 0