I am trying to access a HTTPS request, but When I am trying to access it from my Android app it does not reach to server but the same url is working fine from chrome http client.
Here is my code for POST HTTP request
public String POST(String url){
InputStream inputStream = null;
String result = "";
try {
String jsonreply;
StringBuilder builder = new StringBuilder();
HttpClient client = getNewHttpClient();
HttpPost httpPost = new HttpPost(url);
Log.d(TAG, "URLS"+url);
try {
HttpResponse response = client.execute(httpPost);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (statusCode == 200) {
HttpEntity entity = response.getEntity();
InputStream content = entity.getContent();
BufferedReader reader = new BufferedReader(
new InputStreamReader(content));
String line;
while ((line = reader.readLine()) != null) {
builder.append(line);
}
} else {
Log.d(TAG, "Status code"+statusCode);
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
jsonreply = builder.toString();
return jsonreply;
} catch (Exception e) {
Log.d("InputStream", e.getLocalizedMessage());
}
// 11. return result
return result;
}
the code is always is returning statusCode 404(Not Found). I am very sure that url is correct as I am accessing same url in my other apps too. I can not provide the original url but the fake but similar is this one
https://test.test.se/user_session.json?email=test.test%40gmail.se&password=>Test12345%21%40%23%24&brand=LGE&phonemodel=Nexus+5&os_version=4.4.4&os_type=Android
Thanks for help