Retrofit2 null内容响应正文,响应代码= 200

时间:2016-05-15 17:07:19

标签: android rest neo4j retrofit2

我尝试使用Retrofit2向Neo4j服务器发送请求。

服务界面如下所示:

Retrofit client = new Retrofit.Builder()
                .baseUrl(Globals.BASE_CLIENT_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();

PhonebookContactAPI service = client.create(PhonebookContactAPI.class);

Call<List<PhonebookContact>> call = service.getContacts("PhoneBook");
call.enqueue(new Callback<List<PhonebookContact>>() {
    @Override
    public void onResponse(Call<List<PhonebookContact>> call, Response<List<PhonebookContact>> response) {

        Log.d("Call request", call.request().toString());
        Log.d("Response raw", String.valueOf(response.raw().body()));
        Log.d("Response code", String.valueOf(response.code()));

        if(response.isSuccessful()) {
            Log.d("Response body", new Gson().toJson(response.body()));
        }

        else  {
            Log.d("Response errorBody", String.valueOf(response.errorBody()));
        }

    }

    @Override
    public void onFailure(Call<List<PhonebookContact>> call, Throwable t) {
        Log.d("onFailure", t.toString());
    }
});

当我致电该服务时:

05-15 18:51:58.777 D/Call request: Request{method=GET, url=http://myneo4jserver.com/db/data/label/PhoneBook/nodes, tag=null}
05-15 18:51:58.777 D/Response raw: retrofit2.OkHttpCall$NoContentResponseBody@aec27d4
05-15 18:51:58.777 D/Response code: 200
05-15 18:51:58.791 D/Response body: [{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}]

我收到了这个堆栈跟踪:

index('sawyer.txt',['hello','cloud','cherry','tree'])  

hello 824,965
cloud 583, 16403
cherry 345, 561, 7891
tree 11, 45, 651

正如您所看到的,正文包含正确数量的项目,但它们都是空的。

有什么问题?

0 个答案:

没有答案