There is such a working code block for retrofit2
OkHttpClient okHttpClient = new OkHttpClient(); Retrofit retrofit = new Retrofit.Builder() .baseUrl(BaseSpiceService.URL_SITE+"/") .addConverterFactory(GsonConverterFactory.create()) .client(okHttpClient) .build(); ServerConnectionService scs = retrofit.create(ServerConnectionService.class); baseResponse = scs.updateMe1(map, body).execute().body(); Log.e("UpdateMeRequest", "loadDataFromNetwork: baseResponse code = " +baseResponse.getCode() ); Log.e("UpdateMeRequest", "loadDataFromNetwork: baseResponse message = " +baseResponse.getMessage() ); How can I integrate 404 status processing from the server and from there the message code and the message itself?
Separately caused the body of the error using
String s = scs.updateMe1(map, body).execute.errorBody(); then this line in JsonObject also got on keys. But then, in the absence of 404 status from the server, such code was not executed.
How can I combine my code block and error handling in one thread?
And it would be great if I could access the status of the server codes and the html address, which is usually stored in the variable retrofit - after starting the stream
The interface is:
@Multipart @retrofit2.http.POST("v1/me") Call<BaseResponse> updateMe1(@retrofit2.http.QueryMap Map<String, String> stringMap, @Part MultipartBody.Part file);
Responce<PespoceBody> response = scs.updateMe1(map, body).execute()and then watch what response is:if(response.isSuccessful()){respose.body();} else {response.errorBody()}- Yuriy SPb ♦