Reputation: 317
I am getting the response from the server all right, using retrofit 2.0.1, Is there any way to get the HTTP response status, without using Asynchronous method?
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://192.168.8.4/********/***/")
.addConverterFactory(GsonConverterFactory.create())
.build();
RequestInterface request = retrofit.create(RequestInterface.class);
HotelDetail hd;
Call<HotelDetail> call1 = request.getIndividualHotel("1");
hd = call1.execute().body();
Upvotes: 2
Views: 2327
Reputation: 146
You can store it in Response type and then execute it. Response provides the functionality to retrieve codes via .code() method.
Response response = call1.execute();
System.out.println(response.code());
hd = (HotelDetail) response.body();
System.out.println(hd.toString());
Upvotes: 5