1

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?

stack Learner
  • 1,318
  • 3
  • 18
  • 35

2 Answers2

1

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

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

coroutineDispatcher
  • 7,718
  • 6
  • 30
  • 58
0

There is no / (slash) in your base url as well as in the interface function. So the request becomes like "https://hello.example.com:344new/search/result " which will give u an error. Add slash at the end of your base url like this "https://hello.example.com:344/"

Cassius
  • 353
  • 3
  • 16