首页 > 解决方案 > 在响应代码 400 上,我无法进行数据改造

问题描述

private void getotp(String name,String phone, String dob){
        btnVerify.setClickable(false);
        dialog.show();
        //Toast.makeText(BookToken.this,blockname,Toast.LENGTH_LONG).show();
        Retrofit retrofit = RetrofitClient.getRetrofitInstance();
        apiInterface api = retrofit.create(apiInterface.class);
        Call<otp> call = api.SendOtp("covishield",dose,age, blockname, location, phone);
        call.enqueue(new Callback<otp>() {
                         @Override
                         public void onResponse(Call<otp> call, Response<otp> response) {
                             if (response.code() == 200) {
                                otp resp = response.body();
                                String Success = resp.getSuccess();
                             
                         
                                 dialog.cancel();

   if (response.code() == 200) {
otp resp = response.body();
                                String msg= resp.getMessage();
                                 dialog.cancel();
                                 btnVerify.setClickable(true);
}
                             }else {
                                
                                 dialog.cancel();
                                 btnVerify.setClickable(true);
                               
                             }

                         }



            @Override
            public void onFailure(Call<otp> call, Throwable t) {

                Toasty.error(BookToken.this, "SomeThing Went Wrong", Toast.LENGTH_SHORT, true).show();

                dialog.cancel();
                
            }
        });
    }

这里是响应代码 400 api echo json data on value message,但是在我的方法上,如果我尝试获取消息,我可以得到消息,由于空对象引用,它的改造或 httpintercepter 错误,我们将强制关闭?请让我知道

标签: android-studioretrofitretrofit2httpinterceptor

解决方案


推荐阅读