The situation is as follows

public void requestAllJobs() { Retrofit retrofit = new Retrofit.Builder() .baseUrl(Constants.URL) .addConverterFactory(GsonConverterFactory.create()) .build(); 

Where

 public static final String URL = "http://openapi.ro/api/addresses.json?description=Bucuresti"; 

Produces the following error

Caused by: java.lang.IllegalArgumentException: baseUrl must end in /: http://openapi.ro/api/addresses.json?description=Bucuresti

Please tell me what could be the problem?

    1 answer 1

    baseUrl is the path to the root of the API, not the URL of a particular call with parameters. You are still only building a copy of the Retrofit by the builder, and not pulling a particular challenge.

    In your case, the baseUrl will be http://openapi.ro/api/

    It looks like you are somehow wrong trying to use Retrofit. You will specify the paths to specific calls in the service interface as follows:

     interface OpenApiService { @GET("addresses.json") Call<List<Job>> requestAllJobs(@Query("description") String description); } 

    and in Retrofit register your interface and get a copy of the service:

     Retrofit retrofit = new Retrofit.Builder() .baseUrl("http://openapi.ro/api/") .addConverterFactory(GsonConverterFactory.create()) .build(); OpenApiService service = retrofit.create(OpenApiService.class); 

    then you can call him:

     Call<List<Job>> jobs = service.requestAllJobs("Bucuresti"); 
    • Thanks. Also, if the link of the type / cars & lang = ru is to write something: Call <List <TextNumeric >> getJSON (@Query ("cars & lang") String cars); - Morozov