How Do I Send Json As Body In A Post Request To Server From An Android Application?
I am working on my first Android Application. What I am trying to do is a POST request to a REST service I want the BODY of this request to be a JSON String. I am using google's
Solution 1:
Sorry folks, just turned out that the error was on the Rest service. I had change it and now it receives a String instead of the Reader object and it works as expected, the REST endpoint code on the server side now is:
@POST@Path("/cadastrar/{userEmail}")
@Consumes(MediaType.APPLICATION_JSON)
publicStringcadastraPeso(@PathParam("userEmail") String email, String jsonString)
{
String json = jsonString;
if(json != null)
{
log.debug("String json received from device ==>> " + json);
}
return"OK - processed email ==>> " + email;
}
And the JSON string is correctly received on server side.
So de Android code above is working as expected.
Post a Comment for "How Do I Send Json As Body In A Post Request To Server From An Android Application?"