String response =
null;
DefaultHttpClient
httpClient = new DefaultHttpClient();
ResponseHandler
<String> resonseHandler = new BasicResponseHandler();
HttpPost
postMethod = new HttpPost("your url");
try
{
JSONObject json = new JSONObject();
json.put("Fiedl1”,value1);
json.put("Fiedl2",value2);
postMethod.setEntity(new ByteArrayEntity(json.toString().getBytes("UTF8")));
postMethod.setHeader( "Content-Type", "application/json" );
response
= httpClient.execute(postMethod,resonseHandler);
}
catch(Exception e)
{ e.printStackTrace();
}
No comments:
Post a Comment