I have looked at several answered posted here and on Google and am still confused why I am getting this error. The json variable I created reads out I do not have permission. I changed the permissions to allow all and this did not solve the error. I also played around with my URL using my computers IP address of 196.... and the online examples of 127.0.0.1. When I use my IP I get the above error. When I used the 127.0 I get failed to connect error, which I assume is because the IP address does not go anywhere. I tested my PHP code and it input data into MySQL db. So I know that my problem is in my java code. I am posting my code below and trying to post minimal code so I do code dump. If you want me to post more code let me know.
try {
// check for request method
if(method.equals("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.equals("GET")){
// request method is GET
DefaultHttpClient httpClient = new DefaultHttpClient();
String paramString = URLEncodedUtils.format(params, "utf-8");
url += "?" + paramString;
HttpGet httpGet = new HttpGet(url);
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 + "
");
}
is.close();
json = sb.toString();
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
// 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 JSON String
return jObj;
So what do I need to do to get permission?
The Error message I am getting for
catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
is:
Error parsing data org.json.JSONException: Value DOCTYPE of type java.lang.String cannot be converted to JSONObject