【发布时间】:2017-06-05 01:52:21
【问题描述】:
1.这是我使用改造错误的时候
第一步:
public interface RequestService {
@POST ("home/indexThree")
Call<RequestBody> getHomeinfo(@Body RequestBody info);
}
第二步:
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());
}
});
我在网上搜索了很长时间。但是没有用。请帮助或尝试提供一些想法如何实现这一目标。谢谢!
【问题讨论】:
-
哪个错误?可以给logcat吗?
-
您的问题非常不清楚,但可能与stackoverflow.com/questions/30358545/…重复
-
log: java.lang.RuntimeException: 无法调用 public okhttp3.RequestBody() with no args