How do I send JSon as BODY In a POST request to server from an Android application?

為{幸葍}努か 提交于 2019-11-29 09:22:08

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)
public String cadastraPeso(@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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!