There is a website, the backend works in Java, the links look like this:

http://site.ru/user/192718/?wicket:interface=:5:addFriend::ILinkListener:: 

There are also intricate links, where in the end there is any kind of porridge ... Initially, I wrote everything on Retrofit without testing anything. Later it turned out that the Path annotation does not work after the question mark. I copied everything to another library and it turned out a wild horror. Now I look back towards Retrofit and I can’t figure out how to make the @Path annotation work after the question mark? Or maybe some other is for these cases. Or even write your own.

 @GET("http://site.ru/user/{userId}/?wicket:interface=:{session}:addFriend::ILinkListener::") Call<Document> addFriend(@Path("userId") long userId, @Path("session") long session); 

Reluctance to do all sorts of methods to form links or use the @Url annotation. All this will not look profitable

Open Issue # 2535 on github.

    1 answer 1

    Came up with a "hack". We write all the methods of the interface, indicating instead of the question mark its inverted analog (any other can be, but it is more similar)

     @GET("user/{userId}/¿wicket:interface=:{session}:addFriend::ILinkListener::") Call<Document> addFriend(@Path("userId") long userId, @Path("session") long session); 

    And we write such an Interceptor :

     public class URLInterceptor implements Interceptor { @Override public Response intercept(Interceptor.Chain chain) throws IOException { Request original = chain.request(); String originalUrl = original.url().toString(); Request request = original.newBuilder(). method(original.method(), original.body()). url(originalUrl.replace(URLEncoder.encode("¿", "UTF-8"), "?")). build(); Response response = chain.proceed(request); return response; } } 

    Thus, Retrofit does not initially know that there is a question mark ...

    HACK STILL NOT CHECKED