I have the following error in the volley "jsonexception: end of input at char 0"

1

Sending the request the server behaves with no error, but on the side of the response it generates the following error "com.android.volley.volleyerror java.lang.runtimeException: bad url." I'm using Android studio, WebView and Volley.

MainActivity class;

 Map<String, String> postParam= new HashMap<>();
    postParam.put("username", "admin");
    postParam.put("password", "onblox");


    CustonRequest jsObjRequest = new CustonRequest(
            Request.Method.POST,
            "http//:192.168.0.13:8088/onblox/login",
            postParam,
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    Toast.makeText(MainActivity.this,response.toString(),Toast.LENGTH_LONG).show();
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Toast.makeText(MainActivity.this,error.toString(),Toast.LENGTH_LONG).show();
                }
            });

    rq.add(jsObjRequest);

CustonRequest class:

public class CustonRequest extends Request<JSONObject> {
private Response.Listener<JSONObject> response;
private Map<String,String> parm;


public CustonRequest(int method, String url, Map<String,String> parm, Response.Listener<JSONObject> response, Response.ErrorListener listener) {
    super(method, url, listener);
    this.response = response;
    this.parm = parm;
}
public CustonRequest( String url, Map<String,String> parm, Response.Listener<JSONObject> response, Response.ErrorListener listener) {
    super(Method.GET, url, listener);
    this.response = response;
    this.parm = parm;
}

public  Map<String,String> getParm()throws AuthFailureError{
    return parm;
}
@Override
protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
    try {
        String js = new String(response.data, HttpHeaderParser.parseCharset(response.headers));
        return (Response.success(new JSONObject(js),HttpHeaderParser.parseCacheHeaders(response)));
    }catch (UnsupportedEncodingException e){
        e.printStackTrace();
    }catch (JSONException e){
        e.printStackTrace();
    }
    return null;
}

@Override
protected void deliverResponse(JSONObject response) {
    this.response.onResponse(response);
}

}

    
asked by anonymous 21.08.2017 / 15:59

1 answer

1

You should be getting an empty response, make sure postParam is correct, also check the server part code and if the emulator is actually communicating with the server. I hope I have helped:)

    
22.08.2017 / 02:19