Залп выполнить неверный метод - PullRequest
0 голосов
/ 27 апреля 2020

Я использую библиотеку залпа для отправки данных на сервер как json. Мой сервер успешно ответил. Данные сохраняются в базе данных. Но залп выполнить ErrorResponse, вот мой код

  private  void  upload(final  Context context) {

    String url = BASE_URL + "upload.php";

    RequestQueue requestQueue = Volley.newRequestQueue(context);

    StringRequest stringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {

            Intent intent=new Intent(ProfilePictureActivity.this,HomeActivity.class);
            startActivity(intent);

        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
         //   Log.i("Error", "" + error);

            Toast.makeText(context, "Cannot save", Toast.LENGTH_SHORT).show();
        }
    }) {
        @Override
        protected Map<String, String> getParams() throws AuthFailureError {
            Map<String, String> stringMap = new HashMap<>();


            stringMap.put("name", names);
            stringMap.put("date_of_birth",dobs);
            stringMap.put("address", presentAddress);
            stringMap.put("phone",phone);
            stringMap.put("email", email);
            stringMap.put("image",phone+".jpg");
            stringMap.put("photo",imageToString(bitmap));

            return stringMap;
        }
    };

    requestQueue.add(stringRequest);
}
...