Is there is some solutions to change Retrofit BaseUrl in runtime? I'm using Dagger to make Retrofit instance, but in my case Url is the users input after Application created and launcher activity started.
Asked
Active
Viewed 118 times
1
-
1if you use `@Url` annotation parameter on the method . The base URL will be omitted . U can add @Url String url as a parameter in the API method . – ADM Jul 30 '21 at 10:38
-
@ADM, Retrofit throws an expetion if you using ```@Url``` with ```@POST``` requests – dbuzin Jul 30 '21 at 11:20
-
It Should not . make sure URL is valid with `http://` . If problem still persist then add the code and exception with question . – ADM Jul 30 '21 at 11:34
-
@ADM, sorry, my misstake. To use ```@Url``` request method annotation should be empty (with out any path). Not so elegant solution, but it works. – dbuzin Jul 30 '21 at 12:27
-
Whats not elegant about it ? this is as good as it gets . its better then creating a new RetroFit intance for each request . – ADM Jul 30 '21 at 13:27
-
For baseurl use "fakeurl.com/api" or whatever. And in the okhttpinterceptor, replace that with user input url and then execute the request – denvercoder9 Aug 03 '21 at 17:49