How to setup Retrofit with no baseUrl
<p>My apiPath is fully dynamic. I am having items containing fields such us "ipAddress" and "SSLprotocol". Based on them I can build my url:</p>

<pre><code>private String urlBuilder(Server server) {
    String protocol;
    String address = "";

    if (AppTools.isDeviceOnWifi(activity)) {
        address = serverToConnect.getExternalIp();
    } else if (AppTools.isDeviceOnGSM(activity)) {
        address = serverToConnect.getInternalIp();
    }

    if (server.isShouldUseSSL()) {
        protocol = "https://";
    } else {
        protocol = "http://";
    }
    return protocol + address;
}
</code></pre>

<p>So my protocol + address can be: http:// + 192.168.0.01:8010 = <a href="http://192.168.0.01:8010" rel="noreferrer">http://192.168.0.01:8010</a></p>

<p>And I would like to use it like that:</p>

<pre><code>@FormUrlEncoded
@POST("{fullyGeneratedPath}/json/token.php")
Observable&lt;AuthenticationResponse&gt; authenticateUser(
            @Path("fullyGeneratedPath") String fullyGeneratedPath,
            @Field("login") String login,
            @Field("psw") String password,
            @Field("mobile") String mobile);
</code></pre>

<p>So full path for authenticateUser would be <a href="http://192.168.0.01:8010/json/token.php" rel="noreferrer">http://192.168.0.01:8010/json/token.php</a> - for example.</p>

<p>That means I don't need any basePath because I create whole basePath myself depending on server I want to connect to.</p>

<p>My retrofit setup is:</p>

<pre><code>@Provides
@Singleton
Retrofit provideRetrofit(OkHttpClient okHttpClient,
            Converter.Factory converterFactory,
            AppConfig appConfig) {
    Retrofit.Builder builder = new Retrofit.Builder();
    builder.client(okHttpClient)
            .baseUrl(appConfig.getApiBasePath())
            .addConverterFactory(converterFactory)
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create());

    return builder.build();
}
</code></pre>

<p>If I remove baseUrl then I get error that this parameter is required. So I set my apiBasePath to:</p>

<pre><code>public String getApiBasePath() {
    return "";
}
</code></pre>

<p>And then I get error instantly after I create retrofit instance:</p>

<pre><code>java.lang.IllegalArgumentException: Illegal URL: 
</code></pre>

<p>How to solve it?</p>