简体   繁体   中英

JAX-RS retrieve Entity parameter from post Response java

I am trying to retrieve entities from body response of a POST request

    Client client = ClientBuilder.newClient(new ClientConfig());
    Response response = client.target(url)
            .request(MediaType.APPLICATION_JSON)
            .post(Entity.entity(form,MediaType.APPLICATION_JSON), Response.class);
    Log.trackingResponse(url, response);`

request is 200 OK, parameters I want to retrieve exist, I can see them while debugging:

在此处输入图片说明

My problem is I can not access these parameters.

I tried the following solution but it was not successful:

Map<String, Object> jsonResponse = clientResponse.readEntity(Map.class);

MessageBodyProviderNotFoundException

Order order = response.readEntity(Order.class); 

Order being a custom class with Jacksonannotation, MessageBodyProviderNotFoundException

 String jsonResponse = clientResponse.readEntity(String.class);

returns < ! DOCTYPE html PUBLIC .... the whote html code, but not my parameters

My maven has the correc jackson depedency.

Any idea ? Thanks

These parameters are part of the request you sent, not the response. They are members of the form you sent in the request entity:

.post(Entity.entity(form,MediaType.APPLICATION_JSON), Response.class);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM