I am using Retrofit2 for API parsing.
While using retrofit1.9.0
both post and get methods work properly. But using retrofit 2.1.0
, in the get method, there is an error:
java.lang.IllegalArgumentException: baseUrl must end in /
I have checked my code and there is no problem, it's working for the post method.
Retrofit retrofit= new Retrofit.Builder()
.baseUrl("sample.com/ecomtest/index.php?route=api/")
.addConverterFactory(GsonConverterFactory.create())
.build();
'?' can not in baseUrl, you should move it to API interface. like this.
The full url :https://free-api.heweather.com/v5/now?
city=yourcity&key=yourkey
so, baseUrl = "https://free-api.heweather.com/v5/"
and the API interface
@GET("now?")
Observable<HeWeather5> getNowWeather(@Query("city") String city,@Query("key") String key);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With