performance - Unable to use retrofit android library getting error while compiling -
i using below code call api. have added custom key wont work:
string api_base_url="http://api.themoviedb.org/3/movie/popular? api_key=adfasdfasd/"; retrofit retrofit = new retrofit.builder() .baseurl(api_base_url) .addconverterfactory(gsonconverterfactory.create()) .build(); moviesapi service = retrofit.create(moviesapi.class); call<list<pictures>> pics = service.listpictures();
i have added below dependencies retrofit in gradle:
compile 'com.squareup.retrofit2:retrofit:2.0.1' compile 'com.squareup.retrofit2:converter-gson:2.0.2'
this interface
public interface moviesapi { @get("results") call<list<pictures>> listpictures(); }
i'm getting:
caused by: java.lang.illegalargumentexception: baseurl must end in /: http://api.themoviedb.org/3/movie/popular?api_key=adfasdfasd/ @ retrofit2.retrofit$builder.baseurl(retrofit.java:496) @ retrofit2.retrofit$builder.baseurl(retrofit.java:439) @ com.example.varunbehl.mymovies.mainactivity.oncreate(mainactivity.java:25) @ android.app.activity.performcreate(activity.java:6251) @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1108) @ android.app.activitythread.performlaunchactivity(activitythread.java:2403) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2510) @ android.app.activitythread.-wrap11(activitythread.java) @ android.app.activitythread$h.handlemessage(activitythread.java:1363) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:148) @ android.app.activitythread.main(activitythread.java:5459) @ java.lang.reflect.method.invoke(native method)
i have added / @ end of base url. solution?
the problem method of passing url:
you should pass url below:
string api_base_url="http://api.themoviedb.org/3/;
retrofit retrofit = new retrofit.builder() .baseurl(api_base_url) .addconverterfactory(gsonconverterfactory.create()) .build(); moviesapi service = retrofit.create(moviesapi.class); call<list<pictures>> pics = service.listpictures();
and interface this:
public interface moviesapi { @get("/movie/popular?{api_key}/results") response getmovielist(@path("api_key") string api_key, callback<response> callback);
hope you.
Comments
Post a Comment