I am trying to parse a JSON and fetch data When I tried to fetch data The result seems to be xml document , but in JSONLint and postman it looks fine
The Code I am using is...
private class DownloadJSON extends AsyncTask<Void, Void, Void> {
@Override
protected void onPreExecute() {
super.onPreExecute();
/*mProgressDialog = new ProgressDialog(this,R.style.CustomDialog);*/
mProgressDialog = new ProgressDialog(getActivity(),R.style.MyTheme);
mProgressDialog.setCancelable(false);
mProgressDialog.setProgressStyle(android.R.style.Widget_ProgressBar_Small);
mProgressDialog.show();
}
@Override
protected Void doInBackground(Void... params) {
HttpParams params1 = new BasicHttpParams();
HttpProtocolParams.setVersion(params1, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params1, "UTF-8");
params1.setBooleanParameter("http.protocol.expect-continue", false);
HttpClient httpclient = new DefaultHttpClient(params1);
HttpPost httppost = new HttpPost("");
try{
HttpResponse http_response= httpclient.execute(httppost);
HttpEntity entity = http_response.getEntity();
String jsonText = EntityUtils.toString(entity, HTTP.UTF_8);
Log.i("Response", jsonText);
jsonobject = new JSONObject(jsonText);
}catch(Exception e){
}
return null;
}
@Override
protected void onPostExecute(Void args) {
mProgressDialog.dismiss();
}
}
The Response I am getting is
09-02 16:03:03.556: I/Response(4575): ?<?xml version="1.0" encoding="utf-8"?>
09-02 16:03:03.556: I/Response(4575): <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
09-02 16:03:03.556: I/Response(4575): <html xmlns="http://www.w3.org/1999/xhtml">
09-02 16:03:03.556: I/Response(4575): <head>
09-02 16:03:03.556: I/Response(4575): <title>Service</title>
09-02 16:03:03.556: I/Response(4575): <style>BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; } #content { margin-left: 30px; font- size: .70em; padding-bottom: 2em; } A:link { color: #336699; font-weight: bold; text-decoration: underline; } A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; } A:active { color: #336699; font-weight: bold; text-decoration: underline; } .heading1 { background-color: #003366; border-bottom: #336699 6px solid; color: #ffffff; font-family: Tahoma; font-size: 26px; f ont-weight: normal;margin: 0em 0em 10px -20px; padding-bottom: 8px; padding-left: 30px;padding-top: 16px;} pre { font-size:small; background-color: #e5e5cc; padding: 5px; font-family: Courier New; margin-top: 0px; border: 1px #f0f0e0 solid; white-space: pre-wrap; white-space: -pre-wrap; word-wrap: break-word; } table { border-collapse: collapse; border-spacing: 0px; font-family: Verdana;} table th { border-right: 2px white solid; border-bottom: 2px white solid; font-weight: bold; background-color: #cecf9c;} table td { border-right: 2px white solid; border-bottom: 2px white solid; background-color: #e5e5cc;}</style>
09-02 16:03:03.556: I/Response(4575): </head>
09-02 16:03:03.556: I/Response(4575): <body>
09-02 16:03:03.556: I/Response(4575): <div id="content">
09-02 16:03:03.556: I/Response(4575): <p class="heading1">Service</p>
09-02 16:03:03.556: I/Response(4575): <p xmlns="">Method not allowed.
Please see the <a rel="help-page" href="http://com/API.svc/help">service help page</a> for constructing valid requests to the service.</p>
09-02 16:03:03.556: I/Response(4575): </div>
09-02 16:03:03.556: I/Response(4575): </body>
09-02 16:03:03.556: I/Response(4575): </html>
Everything works fine on IOS and parse result is perfect. I tried few other methods too but response is the same, It will be great if somebody help me to sort out this trouble