android retrofit

Retrofit – Change BaseUrl

I have a scenario where I have to call an API with the same base URL, e.g. but with a different baseUrl.

I have an instance of Retrofit 2 which is built via a Builder:

return new Retrofit.Builder()

The FlavourConstants.BASE_URL looks like this:

public static final String BASE_URL = "http://myApi.development:5000/api/v1/";

For some WebRequests, I must call the same API but on others, I must call it from a completely different BaseUrl. How do I change the Retrofit instance to therefore point to a different URL during runtime?

The Retrofit instance doesn’t have a .setBaseUrl or setter or anything similar as it’s built via a Builder.

Any ideas?