java - 获取模型尚未初始化。请先 buildModel 进行改造 api 调用
问题描述
我正在以这种方式进行改造电话:-
APIInterface apiInterface = APIClient.getClient().create(APIInterface.class);
AppLogger.getInstance().e("TAG", "Request visit: " +obj1);
Call<ResponseBody> call1=apimethod(obj1);
call1.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
AppLogger.getInstance().e("TAG", "Response add " + response.body()
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
AppLogger.getInstance().e("Tag", "Response add " +t);
}
});
我的 API 调用就像:-
@POST("route for the route")
Call<ResponseBody> apimethod(@Body Class1 obj);
我正在以这种方式初始化改造对象:-
public static Retrofit getClient() {
HttpsTrustManager.allowAllSSL();
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();
client=getUnsafeOkHttpClient().build();
retrofit = new Retrofit.Builder()
.baseUrl("<apiurl>")
.addConverterFactory(GsonConverterFactory.create())
.client(getUnsafeOkHttpClient().build())
.build();
return retrofit;
}
但是在提交响应时:- 根据 api 正文,请求正文是正确的
{Object }
最后的反应就像这很奇怪:-
I/okhttp.OkHttpClient: {"timestamp":"2020-06-28T12:28:20.410+0000","status":404,"error":"Not Found","message":"Model has not been initialized. Please buildModel first","path":"<route for it>"}
这里所有细节都被初始化但无法理解为什么这说模型没有初始化
解决方案
推荐阅读
- odoo - 我如何在odoo 10中获得金额
- python - 将 Pandas 数据帧从本地机器上传到 Google Cloud 存储桶
- php - 将 DateTime 字符串转换为 DateTime 对象,返回布尔值而不是对象
- machine-learning - 训练集中与测试集中不同的攻击类型(标签)
- javascript - 加载 React 应用程序时如何设置 firebase auth onAuthStateChanged() 监听器运行?
- xml - XSLT 正在为每一行创建单独的表。我如何把它们变成一张桌子?
- ios - NSTextAttachment() 额外属性
- sql - PostgreSQL - 生成每小时列表
- macos - Embedded Postgres 在 Mac OS 上无法获取进程 PID
- ruby - 如何解决 Rubocop 错误 'Favor `format` over `String#%`'