엔드 포인트가없는 "GET"요청을 보내려합니다. 요청을 보내면 내 "onFailure"메소드에서 응답을 얻습니다. 개장 2 엔드 포인트가없는 GET 요청?
이
내 URL입니다 : http://api.gios.gov.pl/pjp-api/rest/station/findAll (나는 우체부에이 URL을 입증하고, 거기에 한 나는 올바른 응답을 얻을 수 있습니다)이 내 개조 클라이언트입니다:
여기 private static final String BASE_URL = "http://api.gios.gov.pl/pjp-api/rest/station/findAll/";
private static Retrofit retrofit = null;
public static Retrofit getRetrofitClient(String url){
if(retrofit==null){
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
return retrofit;
}
이 인터페이스입니다 :
MainActivity에서 @GET()
Call<ServerResponse> showTheStations(@Url String url);
내 응답 방법 :
public void retrofitRespond(){
retrofitInterface = ApiUtil.getRetrofitInterface();
retrofitInterface.showTheStations("http://api.gios.gov.pl/pjp-
api/rest/station/findAll").enqueue(new Callback<ServerResponse>() {
@Override
public void onResponse(Call<ServerResponse> call, Response<ServerResponse> response) {
}
@Override
public void onFailure(Call<ServerResponse> call, Throwable t) {
Toast.makeText(getApplicationContext(),"WENT WRONG", Toast.LENGTH_LONG).show();
}
});
어떻게해야 제대로 할 수 있습니까? Retrofit 2에서 동적 URL에 대해 읽었지만 제대로 처리 할 수 없습니다.
당신이 오류를 게시 할 수 있습니다 ...? – tebitoq
오류가 없습니다. "public void onFailure"메서드가 내 응답을 포착하고 있습니다. 나는 어떤 응답을 알아낼 수 없다. 코드()는 내가 – Adam
@Adam onFailure()에서 Error.e (TAG, t.toString())를 추가하는 것을 볼 수있다; –