Feign - URL encode path params

feign, netflix-feign, spring-boot

Solution

A simple config did it,

@RequestLine(value = "GET /products/{id}", decodeSlash = false)
@Headers({"Content-Type: application/json"})
ApiResponse getProduct(@Param("id") String productId) throws Exception;

The path param was correctly getting encoded but the RequestTemplate was decoding the URL again (decodeSlash=true by default) before sending out the request which was causing the issue.

Problem

This is my contract, ``` @RequestLine("GET /products/{id}") @Headers({"Content-Type: application/json"}) ApiResponse getProduct(@Param("id") String productId) throws Exception; ``` I want to fetch the product with id = "a/b", If I send this as a param to `getProduct("a/b")` then the URL that is formed is `http://api/products/a/b` and I am getting a 404 instead the url should be `http://api/products/a%2Fb` Is there a way around this?

Original source