簡體   English   中英

改裝發布請求未從Server Android獲得響應

[英]Retrofit Post request doesn't get response from Server Android

我從Log貓中的Okhttp Logging攔截器得到響應。 但是我無法在郵寄電話的改造響應中得到它。 這是我的電話:

private void update(PostEntity postEntity){
    Call<ResponseEntity> call = baseProvider.getApiClient().
            createNewQuestion(mPrefs.getLoggedUserCityId(), postEntity);

    call.enqueue(new Callback<ResponseEntity>() {
        @Override
        public void onResponse(Call<ResponseEntity> call, Response<ResponseEntity> response) {
            Log.i("post:", response.body().toString());
        }

        @Override
        public void onFailure(Call<ResponseEntity> call, Throwable t) {
            Log.i("Not Working", "Retrofit is not updating the feed!!");
        }
    });
}

D / OkHttp:OkHttp-Sent-Millis:1471598299803
D / OkHttp:OkHttp收到的Millis:1471598300522
D / OkHttp:{“消息”:“已成功發布”,“ uuid”:“ 5dgiriWE4s4Sqhts”}

在這里我得到response.body()。toString是好的。 我無法獲取okhttp攔截器輸出,無法從服務器存儲uuid。

我假設response.body().toString()將返回類似

ResponseEntity("message":"Posted Successfully","uuid":"5dgiriWE4s4Sqhts")

因此,如果要提取值(例如,如果要從中獲取uuid ,則必須執行以下操作(假設您的ResponseEntity類具有gettersetter方法)

String udid=(ResponseEntity)(response.body()).getUDID()

希望您能從中得到啟發。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM