java - JAX-RS response.getEntity returns null after post -


when invoke next code:

response response = target.request(mediatype.application_json_type)                 .post(entity.entity(form, mediatype.application_form_urlencoded_type));  response.getentity(); 

response.getentity() null.

but when invoke:

jsonobject json = target.request(mediatype.application_json_type)                 .post(entity.entity(form, mediatype.application_form_urlencoded_type), jsonobject.class); 

variable json not null.

i need use first variant because need check response status.

why first code not working?and how can status code then?

you need use response.readentity(your.class) return instance of type want. example

string rawjson = response.readentity(string.class); // or jsonobject jsonobject = response.readentity(jsonobject.class); 

note there needs provider handle reading java type , application/json. if using jersey , json-p api, see this. general information providers, see this


Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

wpf - C# NAudio - Changing audio playback position still plays a small buffer of old position -

Inno-Setup: use own button texts on messagebox -