A
A
afna2015-09-11 16:08:03
Java
afna, 2015-09-11 16:08:03

How to send POST json data to body via WebView?

Welcome all!
Android.
There was a task to send POST request through WebView. The request must contain json in the body.
How can this be implemented?
google did not help (I only found sending data in the parameters, but I need it in the body).
Or can you suggest an alternative?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LeEnot, 2015-09-11
@LeEnot

Those. like this:

HttpPost httpost = new HttpPost("http://...");
httpost.setEntity(new StringEntity("{\"param_name\":\"param\"}"));
httpost.setHeader("Accept", "application/json");
httpost.setHeader("Content-type", "application/json; charset=UTF-8");
HttpResponse response = httpClient.execute(httpPost);

doesn't work for you?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question