Here is my interface.
public interface SCIMServiceStub {
@RequestLine("GET /Users/{id}")
SCIMUser getUser(@Param("id") String id);
@RequestLine("GET /Groups?filter=displayName+Eq+{roleName}")
SCIMGroup isValidRole(@Param("roleName") String roleName);
}
Here getUser
call works fine. But isValidRole
is not working properly as the request is eventually sent like this.
/Groups?filter=displayName+Eq+{roleName}"
Here {roleName}
is not resolved. What am I missing here? Appreciate some help, as I'm clueless at this point.
Edit: 1 more question: Is there a way to avoid automatic url encoding of query parameters?
Query parameters can be configured in Feign clients by using the @RequestParam annotation from the Spring web framework on method arguments which should be passed as query parameters when calling the remote service.
Spring WebClient is a non-blocking reactive client to make HTTP requests. Feign is a library which helps us to create declarative REST clients easily with annotations and it provides better abstraction when we need to call an external service in Microservices Architecture.
Feign has a way to provide the dynamic URLs and endpoints at runtime. The following steps have to be followed: In the FeignClient interface we have to remove the URL parameter. We have to use @RequestLine annotation to mention the REST method (GET, PUT, POST, etc.):
Feign client is really convenient tool to use. But I recently came to know that Rest-Template is going to be deprecated and will be replaced by WebClient, and Feign Client internally uses Rest-Template.
Working fine using @QueryMap
URL: /api/v1/task/search?status=PENDING&size=20&page=0
Map<String, String> parameters = new LinkedHashMap<>()
parameters.put("status", "PENDING")
parameters.put("size", "20")
parameters.put("page", "0")
def tasks = restClientFactory.taskApiClient.searchTasks(parameters)
Inside Client Interface
@RequestLine("GET /api/v1/task/search?{parameters}")
List<Task> searchTasks(@QueryMap Map<String, String> parameters)
With Spring feign client below works fine :
@GetMapping("/Groups?filter=displayName+Eq+{roleName}")
SCIMGroup isValidRole(@PathVariable(value = "roleName") String roleName);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With