I used to post json stringer using the following code but having lot of deprecation warning.Can anyone help me out to show me the correct way for POSTing.Please have a look on my code that i'm using for posting currently.
HttpPost httppost = new HttpPost(F_URL);
System.out.println("URL...." + F_URL);
httppost.setHeader("Accept", "application/json");
httppost.setHeader("Content-Type", "application/json");
JSONStringer jsonStringer = new JSONStringer().object()
.key("putmicdata").object().key("CompanyID")
.value(companyid).key("ValueHeader")
.value(valueheader).key("ValueHeaderDetail")
.value(valueheaderdetail).endObject();
StringEntity entity = new StringEntity(
jsonStringer.toString());
System.out.println("String...."
+ jsonStringer.toString());
entity.setContentType(new BasicHeader(
HTTP.CONTENT_TYPE, "application/json"));
httppost.setEntity(entity);
response = httpclient.execute(httppost);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
System.out.println("StatusCode for MIC" + statusCode);
if (response != null) {
HttpEntity httpEntity = response.getEntity();
total = EntityUtils.toString(httpEntity);
dbhelper.getWritableDatabase();
dbhelper.DELETE_MICUOMINTERNAL(loc);
dbhelper.closeDatabase();
}
result = "success";