Retrofit 2 removes posrt after special character “:” from base Url

Refresh

April 2019

Views

10 time

0

I have an Api https://hello.example.com:344/new/search/result. Implementing same using Retrofit 2:

This is how initialising retrofit:

  public static void initializeRetrofit() {
        Retrofit retrofit = new Retrofit.Builder().baseUrl("https://hello.example.com:344")
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .build();
        service2 = retrofit.create(ContentService.class);
    }

This is the interface request:

 @POST("new/search/result")
    Call<JsonObject> getSearchList(@Body JsonObject request);

But when i hit api : it removes the port from it and hits

"https://hello.example.com/new/search/result"

What is going wrong?

1 answers

0

In your base url "https://hello.example.com:344" transform it to

"https://hello.example.com:344/"