Android : Http 400 error coe in Hiting Api in android the URL is " http://khanhzpz.vn/CRM/modules/Mobile/api.php"

on Saturday, September 20, 2014


I wants to hit this link in for login in http://khanhzpz.vn/CRM/modules/Mobile this site but every time it returns the HTTP 400 error code. if i hit this website url("http://khanhzpz.vn/") only then also it shows same error.


i also used the REST Api Library,Normal HTTP hit,Volley Library. please help me out .. Here is my Function to hit api.



public void postData() {
try {
String url = "http://khanhzpz.vn/CRM/modules/Mobile/";
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(new HttpGet(url));
StatusLine statusLine = response.getStatusLine();

AndroidHttpClient httpClient = AndroidHttpClient
.newInstance("User Agent");

// String url = "http://khanhzpz.vn/CRM/modules/Mobile/";
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("username", "sarbjot"));
nameValuePairs.add(new BasicNameValuePair("password", "1235"));
URL urlObj = new URL(url);
HttpHost host = new HttpHost(urlObj.getHost(), urlObj.getPort(),
urlObj.getProtocol());
AuthScope scope = new AuthScope(urlObj.getHost(), urlObj.getPort());
HttpContext credContext = new BasicHttpContext();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

// Execute post request and get http response
HttpResponse httpResponse = httpClient.execute(host, httpPost,
credContext);
String responseBody = EntityUtils
.toString(httpResponse.getEntity());
System.out.println("response :" + responseBody);
httpClient.close();
} catch (Exception e) {
e.printStackTrace();
}

}


if i hit facebook.com it returns sucess 200 ok statusLine.


thanks in advance.


0 comments:

Post a Comment