У меня есть встроенная версия 2.0 с Android-приложением. Отклик Почтальон работает отлично для API, когда я интегрировать его с андроид приложения, он генерирует внутренняя ошибка сервераПолучить запрос в retrofit порождает ошибку 500 внутренних серверов
MainActivity.java
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Call<List<Result>> results = RetroClient.getApiService().getResponse("application/json");
results.enqueue(new Callback<List<Result>>() {
@Override
public void onResponse(Call<List<Result>> call, Response<List<Result>> response) {
if (response.isSuccessful()) {
Toast.makeText(MainActivity.this,
String.valueOf(response.message()), Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(MainActivity.this,
"ifferror", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailure(Call<List<Result>> call, Throwable t) {
Toast.makeText(MainActivity.this, "failed", Toast.LENGTH_SHORT).show();
}
});
}
}
RetroClient.java
public class RetroClient {
private static final String ROOT_URL = "http://azeemkhan.me/quflip/api/rest/";
private static Retrofit restAdapter;
private static ApiService apiService;
static {
setupRestClient();
}
private static void setupRestClient() {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient okHttpClient = new OkHttpClient.Builder()
.addInterceptor(logging)
.build();
restAdapter = new Retrofit.Builder()
.baseUrl(ROOT_URL)
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
public static ApiService getApiService() {
if (apiService == null) {
apiService = restAdapter.create(ApiService.class);
}
return apiService;
}
}
ApiService.java
public interface ApiService {
@GET("products/3/categories")
Call<List<Result>> getResponse(@Header("Content-Type") String content_type);
}
Result.java
public class Result {
@SerializedName("category_id")
private String entityId;
public String getEntityId() {
return entityId;
}
public void setEntityId(String entityId) {
this.entityId = entityId;
}
}
http://stackoverflow.com/questions/40880577/how-to-do-a-get-request-using-retrofit2/40880645#40880645 –