Hi,

I use that pretty extensively to test some web services that need to receive post request with JSON strings:

   /**
* Sends a JSON string to a specific URL and returns the plain response of the server
    */
   public String sendToWebService(String url, String jsonString){

       DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost post = new HttpPost(url);
       post.setHeader("Content-Type", "application/json");
       post.setEntity(new StringEntity(jsonString,"UTF-8"));

ResponseHandler<String> responseHandler = new BasicResponseHandler();
       String response = httpClient.execute(post,responseHandler);
       return response;
   }

Hope that helps

Florent

Pingwy
27, rue des arènes
49100 Angers



Amiruddin Nagri a écrit :
Hi,

I need to send a JSON string in the body of a post request.

The json is going to be a string in the place of body. Since the interface
to send paramters in post request is name/value based, is there any way I
can send a string in the body of this request.

Regards,
Amiruddin Nagri,
Bangalore, 560008, KA
India

Y! IM : [email protected]
GTalk : [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to