1
我使用下面的代碼消耗休息後服務Jersey客戶端收到錯誤消息體
Client client = ClientBuilder.newClient();
WebTarget target = client.target("wrong url");
Invocation.Builder builder = target.request(MediaType.APPLICATION_JSON);
Response response = builder.post(Entity.entity(param, MediaType.APPLICATION_JSON), Response.class);
正如預期的那樣,我得到錯誤。和狀態代碼400 Bad Request
。但我沒有收到錯誤信息。當我運行response.getStatusInfo()
我得到不好的請求,但我的服務器發送額外的信息。
當我打電話給這個使用postman
我得到正文窗口中的錯誤信息。
那麼如何從響應對象中得到這個錯誤的主體信息呢? 或任何其他方式?