Search code examples
javahttpfeign

Feign Client does not resolve Query parameter


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: One more question: Is there a way to avoid automatic url encoding of query parameters?


Solution

  • It seems to be caused by a bug that is already opened - https://github.com/OpenFeign/feign/issues/424

    Like in comments, you can define your own Param.Expander something like below as a workaround.

    @RequestLine("GET /Groups?filter={roleName}")
    String isValidRole(@Param(value = "roleName", expander = PrefixExpander.class) String roleName);
    
    static final class PrefixExpander implements Param.Expander {
        @Override
        public String expand(Object value) {
            return "displayName+Eq+" + value;
        }
    }