I am building a simple android application where I am making a Login Page and implementing a simple POST web API. Previously it was working fine but suddenly it stops working and now it is always returning me HTML code. Below is my code,
try {
List<NameValuePair> li = new ArrayList<NameValuePair>();
li.add(new BasicNameValuePair("username", "ma@dhdh.com"));
li.add(new BasicNameValuePair("password", "123456dndjsj789"));
li.add(new BasicNameValuePair("key", "ZATXMhjHartjDTrH"));
HttpClient httpClient = new DefaultHttpClient();
HttpEntity httpEntity = null;
HttpResponse httpResponse = null;
HttpPost httppost = new HttpPost("http://www.deal.com.lb/merchant_ws/login_ws.php");
httppost.setHeader("Content-Type", "text/html");
httppost.setHeader("Accept","application/json");
httppost.setEntity(new UrlEncodedFormEntity(li));
httpResponse = httpClient.execute(httppost);
httpEntity = httpResponse.getEntity();
String response = EntityUtils.toString(httpEntity);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Please tell me which code I had wrote wrong. Also this service is also working as GET request. You can try it in browser. In browser it is working properly but in Android code it is not.