【问题标题】:get com.android.volley.servererror with null response获取带有空响应的 com.android.volley.servererror
【发布时间】:2017-06-27 07:22:35
【问题描述】:

我想从图库上传照片。当我从图库上传从相机捕获的图像时,会发生此错误。

截击代码如下:

    StringRequest stringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            Toast.makeText(upload.this,response, Toast.LENGTH_SHORT).show();
        }
    },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {            error.printStackTrace();
                }
            }){
        protected Map<String,String> getParams()
        {
            Map<String,String> params = new HashMap<String, String>();

            params.put("photo",str_photo);
            params.put("title",str_caption);
            params.put("name",str_caption);
            params.put("admin_id",admin_id);
            return params;
        }
    };
    RequestQueue requestQueue = Volley.newRequestQueue(upload.this);
    requestQueue.add(stringRequest);

logcat如下

06-28 10:24:43.442 8774-10428/laurel.wedding E/Volley: [1802] BasicNetwork.performRequest: Unexpected response code 413 for http://teachieparentine.com/Wedding_App/photo_upload.php

【问题讨论】:

  • 你用 Postman 试过同样的 api 吗?

标签: android android-volley


【解决方案1】:

您可以按照下面的链接使用多部分使用 volley 上传图像...

How to upload Image on server using Volley?

【讨论】:

    【解决方案2】:

    在 onErrorResponse() 函数中添加这个,并更新帖子

    error.printStackTrace()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多