I am trying to fit my microprofile RestClient to make GET calls to an external API which expects the format of a date query in the following format:
https://some_uri/?query=date%3A%282022%5C-01%5C-01%29?&fmt=json
The above corresponds to a non-encoded uri of the form: date:(yyyy\-MM\-dd)
. I came across @Encoded for that purpose. I have defined my RestClient like so:
@RegisterRestClient
public interface MyService {
@GET
@Path("release/")
@Encoded
@Produces(MediaType.APPLICATION_FORM_URLENCODED)
MyResponse getReleasesByQuery(
@QueryParam("query") @Encoded String query,
@QueryParam("fmt") String format
);
}
which I invoke like this:
String encodeQuery(LocalDate date) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
var formatted = formatter.format(date);
var query = "date%3A%28" + formatted + "%29"; // corresponds to date:(yyyy-MM-dd)
return query.replace("-", "%5C-");
}
myService.getReleasesByQuery(encodeQuery(Datetime.now()), "json")
However (when enabling the http logging) I see the following getting called instead:
GET /ws/2/service/?query=date%25253A%2525282022%255C-02%255C-12%252529&fmt=json
Which as far as I can tell does encode the % into the UTF counterpart (%25).
So essentially I want to disable the encoding and do it myself instead. Am I misusing or misunderstanding this somehow?
I am on Quarkus version 2.4.1.