-4

How do i display the whole error message? I know its HTML response and not JSON..

how do i see the rest of the <br > to see what the error messsage is?

01-04 15:59:00.710: E/JSON Parser(13508): Error parsing data org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
01-04 15:59:00.720: E/AndroidRuntime(13508): FATAL EXCEPTION: AsyncTask #3
01-04 15:59:00.720: E/AndroidRuntime(13508): Process: com.example.coa, PID: 13508
01-04 15:59:00.720: E/AndroidRuntime(13508): java.lang.RuntimeException: An error occurred while executing doInBackground()
01-04 15:59:00.720: E/AndroidRuntime(13508):    at android.os.AsyncTask$3.done(AsyncTask.java:309)
01-04 15:59:00.720: E/AndroidRuntime(13508):    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
01-04 15:59:00.720: E/AndroidRuntime(13508):    at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
01-04 15:59:00.720: E/AndroidRuntime(13508):    at java.util.concurrent.FutureTask.run(FutureTask.java:242)
01-04 15:59:00.720: E/AndroidRuntime(13508):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
01-04 15:59:00.720: E/AndroidRuntime(13508):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
01-04 15:59:00.720: E/AndroidRuntime(13508):    at java.lang.Thread.run(Thread.java:818)
01-04 15:59:00.720: E/AndroidRuntime(13508): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String org.json.JSONObject.toString()' on a null object reference
01-04 15:59:00.720: E/AndroidRuntime(13508):    at com.example.coa.OfflineSV$SyncScans.doInBackground(OfflineSV.java:419)
01-04 15:59:00.720: E/AndroidRuntime(13508):    at com.example.coa.OfflineSV$SyncScans.doInBackground(OfflineSV.java:1)
01-04 15:59:00.720: E/AndroidRuntime(13508):    at android.os.AsyncTask$2.call(AsyncTask.java:295)
01-04 15:59:00.720: E/AndroidRuntime(13508):    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
01-04 15:59:00.720: E/AndroidRuntime(13508):    ... 3 more
Phantômaxx
  • 36,442
  • 21
  • 78
  • 108
kenz
  • 1
  • 2

2 Answers2

1

Just Log it

String response = getData();

Log.d("Response", response);

try {
    JSONObject json = new JSONObject(response);
} catch (JsonException e) {

}

Though, if you know it is HTML, why are you trying to parse JSON?

Fix the server to always return JSON even in the case of errors before you try to do anything client-side.

Additionally, Eclipse has long been deprecated for Android (going on 2 years)

OneCricketeer
  • 126,858
  • 14
  • 92
  • 185
0

ON the backend, the POST data is inserted into sql. I believe there is an SQL error that's being returned hence the

List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("barcode", sv.getBarcode()));
params.add(new BasicNameValuePair("scannerid", sv.getScanner()));
params.add(new BasicNameValuePair("loccode", sv.getLoccode()));
params.add(new BasicNameValuePair("longitude", sv.getLong()));
params.add(new BasicNameValuePair("latitude", sv.getLat()));
params.add(new BasicNameValuePair("svtime", sv.getSVTIME()));

JSONObject json = jParser.makeHttpRequest(url_create_svruns,
        "POST", params);

Log.d("Create Response", json.toString());

// check for success tag
try {
    int success = json.getInt(TAG_SUCCESS);
OneCricketeer
  • 126,858
  • 14
  • 92
  • 185
kenz
  • 1
  • 2
  • Please don't add "thanks" as answers. Invest some time in the site and you will gain sufficient [privileges](//stackoverflow.com/privileges) to upvote answers you like, which is the Stack Overflow way of saying thank you. If my answer addressed your question, you can accept it using the checkmark. – OneCricketeer Jan 13 '17 at 18:38