feign icon indicating copy to clipboard operation
feign copied to clipboard

URL encoding includes parameter names such as "$skip"

Open berndgoetz opened this issue 2 years ago • 2 comments

Hi All,

I have the folloging feign client:

@FeignClient(name = "MdsDataClient", url = "${integration.mds.host.url}", decode404 = true)
public interface MdsClient {

    @GetMapping(value = "{path}")
    Response get(
            @PathVariable("path") String path,
            @SpringQueryMap(encoded = true) Map<String, String> params,
            @RequestHeader Map<String, String> headerMap);

}

One of the defined parameters of the provided service is called "$skip".

Instead of GET https://services.com/currency/api/v2?rateType=DQ&from=USD&to=EUR&dateFrom=2012-01-01&dateTo=2012-01-01&$top=1&$skip=0, I end up with the following URI https://services.com/currency/api/v2?rateType=DQ&from=USD&to=EUR&dateFrom=2012-01-01&dateTo=2012-01-01&%24top=1&%24skip=0

I also tried the encoded = true setting on the @SpringQueryMap, but that seems to be take only the values and not the keys into account.

Any insights? A bug? By design? Thanks.

berndgoetz avatar Jul 30 '22 21:07 berndgoetz

The resulting URL is correct. %24 is just $ as pct-encoded per the URI template specification. https://datatracker.ietf.org/doc/html/rfc6570. $ is a reserved character in the URI specification and should be percent encoded: https://datatracker.ietf.org/doc/html/rfc3986

kdavisk6 avatar Aug 02 '22 23:08 kdavisk6

@berndgoetz @kdavisk6 i have same issue on OData query option like $filter, any solution or workaround by far? thanks

yhknight avatar Sep 16 '22 07:09 yhknight

There's no workaround needed. The resulting URI is correct, just encoded.

kdavisk6 avatar Oct 07 '22 20:10 kdavisk6