Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Feign recognized GET method as POST

I have a service defined as follow

class Echo {
  private String message; // getters and setters omitted
}

@RequestMapping("/app")
interface Resource {
  @RequestMapping(method = GET)
  Echo echo(@ModelAttribute Echo msg);
}

@RestController
class ResourceImpl implements Resource {
  @Override
  Echo echo(Echo msg) { return msg; }
}

and his client on a different application

@FeignClient(name = "app", url = "http://localhost:8080")
interface Client extends Resource {}

However, when I call resource method

@Autowired
private Resource client;

@Test
public void test() {
  Echo echo = new Echo();
  echo.setMessage("hello");
  client.echo(echo);
}

I got a confusing error message

feign.FeignException: status 405 reading ClientLocal#echo(Echo); content: {"timestamp":1512686240485,"status":405,"error":"Method Not Allowed","exception":"org.springframework.web.HttpRequestMethodNotSupportedException","message":"Request method 'POST' not supported","path":"/app"}

What I did wrong here?

like image 236
ntviet18 Avatar asked Jun 29 '26 01:06

ntviet18


1 Answers

Found the same issue and for me the reason of POST with GET mixing by Feign is usage of Object as request param

was with same error as yours:

@GetMapping("/followers/{userId}/id")
Page<String> getFollowersIds(@PathVariable String userId, Pageable pageable);

added @RequstParam for 2 argument fixed it, like:

@GetMapping("/followers/{userId}/id")
Page<String> getFollowersIds(@PathVariable String userId, @RequestParam Pageable pageable);
like image 153
Oleksandr Yefymov Avatar answered Jul 01 '26 23:07

Oleksandr Yefymov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!