Failed to call public okhttp3.RequestBody () without arguments

1. This is the time when I use upgrade errors

first step:

public interface RequestService { @POST ("home/indexThree") Call<RequestBody> getHomeinfo(@Body RequestBody info); } 

second step:

  Retrofit retrofit = new Retrofit.Builder() .baseUrl(url) .addConverterFactory(GsonConverterFactory.create()) .build(); RequestService requestService = retrofit.create(RequestService.class); RequestBody body = RequestBody.create(JSON, jsonObject.toString()); Call<RequestBody> homeinfo = requestService.getHomeinfo(body); homeinfo.enqueue(new Callback<RequestBody>() { @Override public void onResponse(Call<RequestBody> call, Response<RequestBody> response) { System.out.println("response"+response.body().toString()); } @Override public void onFailure(Call<RequestBody> call, Throwable t) { System.out.println("onFailure"+t.getMessage().toString()); } }); 

I have been searching online for a long time. But to no avail. Please help or try to give some ideas on how to achieve this. Thanks!

+6
source share
5 answers
 Call<LoginModel>call=apiService.getForgotPassword(Utill.encodeString(json));call.enqueue(new Callback<LoginModel>() { @Override public void onResponse(Call<LoginModel> call, Response<LoginModel> response) { pDialog.dismiss(); if (response.body() != null) { LoginModel clientModel = response.body(); if (clientModel.getResult().equalsIgnoreCase("OK")) { Utill.showCenteredToast(LoginActivity.this, clientModel.getResult()); dialog.dismiss(); } else { dialog.dismiss(); Utill.showCenteredToast(LoginActivity.this, clientModel.getResult()); } } } 
0
source

I also met this problem and I found the answer to this question, I think you should write Call<ResponseBody>

0
source

using ResponseBody instead of requestbody , solved my case:

 public interface RequestService { @POST ("home/indexThree") Call<ResponseBody> getHomeinfo(@Body RequestBody info); 

}

0
source

use the correct response model response class from the server, these errors indicate that you are using Call.

-1
source

I met a trial version yesterday, and finally dragged it. Since the retrofit calms down, the call is incorrect, he should call where CallBackBean is the bean that is returned to you for your repeated request. See http://blog.csdn.net/u013795543/article/details/70948978 for details.

-1
source

Source: https://habr.com/ru/post/1263083/


All Articles