-1
我想打後一個服務器,並得到響應主體,以顯示它 但仍然總是得到空字符串得到空應答體retrofit2
這是我的接口類
@POST("peserta/cek")
Call<CekPeserta> cekPeserta(@Body String kode_tiket);
class Factory {
private static PesertaAPI service;
public static PesertaAPI getInstance(){
if (service == null) {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL).addConverterFactory(GsonConverterFactory.create())
.build();
service = retrofit.create(PesertaAPI.class);
return service;
}
else return service;
}
}
和mainClass
PesertaAPI.Factory.getInstance().cekPeserta("SDL8S3").enqueue(new Callback<CekPeserta>() {
@Override
public void onResponse(Call<CekPeserta> call, Response<CekPeserta> response) {
Log.i("post status","sukses");
Log.i("nama = ", String.valueOf(response.body().getName()));
}
@Override
public void onFailure(Call<CekPeserta> call, Throwable t) {
}
});