0

We trying to getting Json response which are services developed in .net webservice. But we are getting error is

   java.lang.IllegalArgumentException: Illegal character in path at index 58: 
url/[{'Region':null,'Zone':null,'Club':null,'Name':null,'Mobile':'12437','BloodGroup':null}]

We used code is:

 HttpPost httppost = new HttpPost(J_URL);//passing URL
// Depends on your web service
                httppost.setHeader("Content-type", "application/json");

                InputStream inputStream = null;
                String result = null;
                try {
                    HttpResponse response = httpclient.execute(httppost);
                    HttpEntity entity = response.getEntity();

                    inputStream = entity.getContent();
                    // json is UTF-8 by default
                    BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"), 8);
                    StringBuilder sb = new StringBuilder();

                    String line = null;
                    while ((line = reader.readLine()) != null) {
                        sb.append(line + "\n");
                    }
                    result = sb.toString();
                    Log.d("Response", result);
                } catch (Exception e) {
                    // Oops
                } finally {
                    try {
                        if (inputStream != null) inputStream.close();
                    } catch (Exception squish) {
                    }
                }

Please do needful Advance Thanks

Naresh Koppera
  • 407
  • 1
  • 6
  • 17
  • Happened to me once, This solved my problem : ;charset=UTF-8, Add this right after application/json inside the " . – Jaeger Feb 05 '16 at 07:45
  • It shld be like this httppost.setHeader("Content-type", "application/json charset=UTF-8"); ? – Naresh Koppera Feb 05 '16 at 07:49
  • httppost.setHeader("Content-type", "application/json;charset=UTF-8"); - the " ; " you forgot it. – Jaeger Feb 05 '16 at 07:49
  • same problem java.lang.IllegalArgumentException: Illegal character in path at index 58: http://abc/labcservice/MyService.svc/Search/[{'Region':null,'Zone':null,'Club':null,'Name':null,'Mobile':'1213456','BloodGroup':null}] – Naresh Koppera Feb 05 '16 at 08:34
  • Check this : http://stackoverflow.com/questions/3753852/how-to-solve-this-exception-illegal-character-in-path – Jaeger Feb 05 '16 at 09:33
  • Before i tried but same response – Naresh Koppera Feb 05 '16 at 10:11

0 Answers0