scoder
scoder

Reputation: 2611

netflix feign issue with query parameters

I am using feign client for some discovery and request.

I am using query parameter in my request

if I hard code like below it works.

@FeignClient("userdetailservice")
public interface UserServiceClient {
@RequestMapping(
            method= RequestMethod.GET,
            value = "/alluser/getmyuser?user=1234")
    String getUserDetails();
    }

But this one does not work, it sending request as 'POST' though I mentioned as GET. Its very strange.

@FeignClient("userdetailservice")
public interface UserServiceClient {
@RequestMapping(
            method= RequestMethod.GET,
            value = "/alluser/getmyuser?user={userid}")
    String getUserDetails(@Param(value = "userid") String userid);
    }

So how to send a query parameters in Feign request.

Upvotes: 0

Views: 5187

Answers (1)

3logy
3logy

Reputation: 2712

All Query parameters will automatically be extracted from the url by a split using the & character and mapped to the corresponding @RequestParam in the method declaration.

So you don't need to specify all the keys the @RequestMapping annotation and there you should only specify the endpoint value.

You can check the answer in the following question :

Upvotes: 1

Related Questions