mcxiaoke / android-volley

DEPRECATED
4.29k stars 1.56k forks source link

JSONObject request not working ? #178

Closed yashkumaratri closed 6 years ago

yashkumaratri commented 7 years ago

This is input side on server in JSON form

{"user_email":"ankur@gmail.com","user_password":"123456"}

The returned JSON file is

Array{"result":{"id":"1","name":"ankur","email":"ankur@gmail.com","address":"b-block","designation":"devloper","department":"development","balanceleave":"5"}}


my code is 

final JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("user_email",login);
            jsonObject.put("user_password",passw);
        } catch (JSONException e) {
            e.printStackTrace();
        }

..............

bs.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.PUT,url, jsonObject, new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject response) {

                        Toast.makeText(Profile.this,"Passes from toast",Toast.LENGTH_LONG).show();
                        pDialog.dismiss();
                    }
                }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(Profile.this,"Error from Toast",Toast.LENGTH_LONG).show();
                        error.printStackTrace();

                    }
                });
                MySingleton.getInstance(Profile.this).addtorequestqueue(jsonObjectRequest);
            }
        });

Whenever I send the request the error listener gets the response , why the response listener doesn't get the response??