Quarkus rest client parameter query encoding

Viewed 2165

I have this quarkus rest api:

@ApplicationScoped
@RegisterRestClient(configKey = "s-api")
@RegisterProvider(LoggingFilter.class)
public interface MyClientAdapter {
   @GET
   @Produces(MediaType.TEXT_PLAIN)
   String search(@QueryParam("lodis") double lodis, 
        @QueryParam("secTcn") String secTcn);

the api works well, but in case I pass this value to the method ussu%os, the rest client encodes it to 'ussu%25os':

restClient.search(28322.2, "ussu%os")

As a result of that the endpoint returns nothing.

So my question is how can I disable that encoding for the queryparam secTcn?

1 Answers

The behaviour of your client is correct - % sign is a reserved character in URIs -see RFC3986. Therefore any client, that wants to pass % in the URI must encode it, resulting in %25 being sent to the server.
It is up to the provider of that API endpoint, to correctly decode the query params to their string literal values. If the provider is Jax-rs, then check the @Encoded annotation, whether the values are passed decode or raw.

Related