2

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?

nano_nano
  • 12,351
  • 8
  • 55
  • 83
  • I've copied your code and in my case It works fine! (I don't know anything about your rest client). But try with: @Consumes(MediaType.TEXT_PLAIN+";charset=utf-8") – Luisao Dec 07 '20 at 18:48
  • @Luisao add that annotation to the method header has no effect. The quarkus rest client is a simple ApplicationScoped interface. I will edit my question. – nano_nano Dec 08 '20 at 08:54

1 Answers1

0

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.

Community
  • 1
  • 1
yntelectual
  • 3,028
  • 18
  • 24