我正在尝试访问使用 Loopback 的生成器生成的后端 API。我正在使用内存数据库来存储数据。目前,我正在本地测试它。当我尝试创建“功能”的新实例时,我在回调中收到此错误:
D/AsyncHttpClient: Headers were overwritten! (Accept | application/json) overwrites (Accept | application/json)
V/AsyncHttpResponseHandler: Progress 210 from 210 (100%)
W/remoting.RestAdapter: HTTP request (string) failed: org.apache.http.client.HttpResponseException: Not Found
/xdesign.georgi.espc E/MainActivity: onError - org.apache.http.client.HttpResponseException: Not Found
这是我的模型图
我的 MainActicity 看起来像这样:
public class MainActivity extends AppCompatActivity {
private static final String TAG = MainActivity.class.getSimpleName();
private Model feature;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
RestAdapter adapter = new RestAdapter(getApplicationContext(), "http://10.0.2.2:8080/api");
ModelRepository featureRepository = adapter.createRepository("Feature");
feature = featureRepository.createObject(ImmutableBiMap.of("name","ANDROID_TEST"));
feature.save(new VoidCallback() {
@Override
public void onSuccess() {
Log.e(TAG,"onSuccess");
}
@Override
public void onError(Throwable t) {
Log.e(TAG,"onError - " + t.toString());
}
});
}
}