title: Wrong JSON result in Android
body: <p>I need to get listview json from php server.having problem with my api,this is my api link</p>
  
  <pre><code>http://staging.homeneedsonline.com/ws/ws_exe_newenq.php?exeId=2
  </code></pre>
  
  <p>In my browser i got proper response. this same url in android asyn task i am getting error response.</p>
  
  <pre><code>{"success":"0","message":"New enquiry not found ."}
  </code></pre>
  
  <p>may be this will be logicless question but i could not find the mistake.Is this Api problem or app problem?what i am doing wrong?</p>
  
  <p>this is my code</p>
  
  <pre><code> protected JSONObject doInBackground(String... args) {
                // Building Parameters
                List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
  
                UserFunctions userFunctions = new UserFunctions();
                HashMap&lt;String, String&gt; user = userFunctions.getExinfo(EnquiryActivity.this);
  
               String userid1 = user.get("exid");
                 System.out.println(userid1);
  
  
                final String URL_LIST1 = "http://staging.homeneedsonline.com/ws/ws_exe_newenq.php?exeId=2";
  
  
                   System.out.println(URL_LIST1);  
                JSONParser jsonParser = new JSONParser();    
  
                JSONObject json = jsonParser.getJSONFromUrl(URL_LIST1, get, params);
                System.out.println(json);
  </code></pre>
  
  <p>getJSONFROmUrl method</p>
  
  <pre><code>public JSONObject getJSONFromUrl(String url,String method, List&lt;NameValuePair&gt; params) {
  
          // Making HTTP request
          try {
              if (method == "POST") {
                  // request method is POST
                  // defaultHttpClient
                  DefaultHttpClient httpClient = new DefaultHttpClient();
                  HttpPost httpPost = new HttpPost(url);
                  httpPost.setEntity(new UrlEncodedFormEntity(params));
  
                  HttpResponse httpResponse = httpClient.execute(httpPost);
                  HttpEntity httpEntity = httpResponse.getEntity();
                  is = httpEntity.getContent();
  
              } else if (method == "GET") {
                  // request method is GET
                  DefaultHttpClient httpClient = new DefaultHttpClient();
                  String paramString = URLEncodedUtils.format(params, "utf-8");
                  url += "?" + paramString;
                  HttpGet httpGet = new HttpGet(url);
                  httpGet.addHeader("Cache-Control", "no-cache");
                  HttpResponse httpResponse = httpClient.execute(httpGet);
                  HttpEntity httpEntity = httpResponse.getEntity();
                  is = httpEntity.getContent();
              }
  
          } catch (UnsupportedEncodingException e) {
              e.printStackTrace();
          } catch (ClientProtocolException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
  
          try {
              BufferedReader reader = new BufferedReader(new InputStreamReader(
                      is, "iso-8859-1"), 8);
              StringBuilder sb = new StringBuilder();
              String line = null;
              while ((line = reader.readLine()) != null) {
                  sb.append(line + "\n");
              }
              is.close();
              json = sb.toString();
              Log.e("JSON", json);
          } catch (Exception e) {
              Log.e("Buffer Error", "Error converting result " + e.toString());
              return null;
          }
  
          // try parse the string to a JSON object
          try {
              jObj = new JSONObject(json);           
          } catch (JSONException e) {
              Log.e("JSON Parser", "Error parsing data " + e.toString());
              return null;
  
          }
  
          // return JSON String
          return jObj;
  
      }
  </code></pre>