This could be pretty much a beginners question but I am struggling to find a solution here.
I have my Laravel based website live and I am trying to design an android application for the same. Using the normal android login functionality (added the code below) I am sending an http post request to my server, however, I get the following error:
Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
Controller method not found.
Now,according to my knowledge I am getting this error because the request somehow is converted to http get request and hence the path is not found. Please find a small snapshot of my code below:
protected String doInBackground(Void... params) {
InputStream is = null;
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost request = new HttpPost("http://my.server.address/users/signin/");
List<NameValuePair> postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("email", "someuser"));
postParameters.add(new BasicNameValuePair("password", "somedata"));
UrlEncodedFormEntity form = new UrlEncodedFormEntity(postParameters);
request.setEntity(form);
HttpResponse response = httpclient.execute(request);
HttpEntity entity = response.getEntity();
is = entity.getContent();
} catch (Exception e) {
Log.e("log_tag", "Error in http connection " + e.toString());
}
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 + "
");
}
is.close();
setResult(sb.toString());
//System.out.println(sb.toString());
// this.jArray = new JSONArray(result);
} catch (Exception e) {
Log.e("log_tag", "Error converting result " + e.toString());
}
return getResult();
}
Edit 1: getSigin Mehtod works (so definitely, the post requests are converted to get)
So, well, I created a getSignin method to check whether my guess was true, and yes, that was the problem, the server somehow interprets the request as GET instead of POST.
Any help here would really appreciated, I have wasted hours on this. Also, please correct me if the approach is wrong.