I have created an Android+iOS app, that uses API to retrieve some content in JSON format. Everything was working well until I migrated all my dedicated server to a new one. In new server, the two apps are no more able to get the JSON as before. When the app is supposed to call API, the app crashes some errors like:
org.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at org.json.JSON.typeMismatch(JSON.java:111)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at org.json.JSONObject.<init>(JSONObject.java:160)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at org.json.JSONObject.<init>(JSONObject.java:173)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at com.krown.eat_out.libraries.JSONParser.getJSONFromUrl(JSONParser.java:43)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at com.krown.eat_out.libraries.UserFunctions.confirmDeal(UserFunctions.java:161)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at com.krown.eat_out.ScreenSlidePageFragment$ConfirmDeal.doInBackground(ScreenSlidePageFragment.java:466)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at com.krown.eat_out.ScreenSlidePageFragment$ConfirmDeal.doInBackground(ScreenSlidePageFragment.java:440)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:295)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
07-13 16:12:11.518 4663-4944/com.krown.eat_out W/System.err: at java.lang.Thread.run(Thread.java:818)
I think it's related with server, but I can't figure out what's the problem. I can't find any info about that in logs..
Here is my code in Android app:
public JSONObject confirmDeal(int valueStartIndex, String deal_id,String imei,String imsi,String android_id){
Log.d("Krown", "UserFunctions >> confirmDeal 1");
webService = URLApi+service_confirm_deal+param_deal_id+deal_id+"&"+param_imei+imei+"&"+param_imsi+imsi+"&"+param_android_id+android_id;
JSONObject json = jsonParser.getJSONFromUrl(webService);
Log.d("Krown", "UserFunctions >> confirmDeal >> webService: "+webService);
Log.d("Krown", "UserFunctions >> confirmDeal 2");
return json;
}
The app crashes at this moment:
webService = URLApi+service_confirm_deal+param_deal_id+deal_id+"&"+param_imei+imei+"&"+param_imsi+imsi+"&"+param_android_id+android_id;
JSONObject json = jsonParser.getJSONFromUrl(webService);
Any idea how I can solve that? I don't know where I am supposed to search for a solution...
EDIT
Here is what I get from server when trying to fetch JSON
07-13 16:32:45.049 12434-12465/com.krown.eat_out I/TAG: Server Response :: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL /eat_out/api/currency was not found on this server.</p><hr><address>Apache/2.4.18 (Ubuntu) Server at dev.krown.ch Port 80</address></body></html>
07-13 16:32:45.103 12434-12465/com.krown.eat_out I/TAG: Server Response :: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL /eat_out/api/latest_deals_day was not found on this server.</p><hr><address>Apache/2.4.18 (Ubuntu) Server at dev.krown.ch Port 80</address></body></html>
07-13 16:32:45.155 12434-12465/com.krown.eat_out I/TAG: Server Response :: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL /eat_out/api/latest_deals_night was not found on this server.</p><hr><address>Apache/2.4.18 (Ubuntu) Server at dev.krown.ch Port 80</address></body></html>
What is thats? I have several websites installed, everything is working well except this API..
EDIT 2
The url I am trying to call is something like that:
http://mywebsite.com/eat_out/api/confirm_deal?deal_id=&imei=000000000000000&imsi=310260000000000&android_id=b798c307f7d128f4
EDIT 3
The URL http://mywebsite.com/eat_out/api/confirm_deal is not reachable, may be it's related.. :(
Not Found
The requested URL /eat_out/api/confirm_deal was not found on this server.
Is possible that this issue could be related with a missing extension in PHP configuration or with PHP directly? I am using PHP 7 in new server.