0
我使用Retrofit v2.0.2
。我無法得到JSON Response
我得到這樣的錯誤[email protected]
,請任何人在這種情況下幫助我。如何在改進版本2.0.2中獲得Json響應?
這是接口:
public interface IdeaInterface {
/*Get zoontype for registeration*/
@GET("api/user/get_zone")
Call<ResponseBody> display();
}
調用改造方法在這裏。
public void Get_Zoontype()
{
reg_progressbar.setVisibility(View.VISIBLE);
/* RestAdapter adapter = new RestAdapter.Builder()
.setEndpoint(Constandapi.ROOT_URL) //Setting the Root URL
.build();*/
// Retrofitnew Retrofit.Builder();
Retrofit adapter = new Retrofit.Builder()
.baseUrl(Constandapi.ROOT_URL)
.build();
IdeaInterface report = adapter.create(IdeaInterface.class);
Call<ResponseBody> call = report.display();
call.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
Log.d("reponcevalues","**** "+response.toString());
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
}
});
這是我的基本網址:
public class Constandapi {
public static final String ROOT_URL = "http://vehiclerescue.in/ideadarpan_beta/";
}
我的build.gradle其中有改裝庫提前
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
感謝。
https://stackoverflow.com/questions/37589588/retrofit-get-string-response –
@NaveenKumar你不覺得我的代碼和你的答案一樣嗎 – Mariyappan
使用這段代碼打印日誌response.body()。string()ins tead response.toString() –