如何在日志中打印我的分段截击请求的请求

时间:2019-01-07 06:54:35

标签: android android-volley

这是我的截击多重请求。但是在后端接收到的请求参数为空。我不确定错误是在前端还是后端。因此,为了确保我要打印请求,我在发送日志。

   String url = Globals.BASE_URL +Globals.PAN_UPLOAD;
    SimpleMultiPartRequest smr = new SimpleMultiPartRequest(Request.Method.POST, url,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    Log.d("Response", response);
                    progressBar.setVisibility(View.GONE);
                    changeUiUpload();
                    try {
                        JSONObject jsonObject = new JSONObject(response);
                        Utils.createSnackBarWithAction(activity,jsonObject.getString("ResponseMessage"));
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            progressBar.setVisibility(View.GONE);
            Utils.createSnackBarWithAction(activity,error.toString());
        }
    }){
        @Override
        public Map<String, String> getHeaders() {
            Map<String, String> params = new HashMap<String, String>();
            params.put("Authorization", "Bearer " + Utils.decrypt(session.getOauthToken()));
            return params;
        }
    };

    smr.addStringParam("auth_token",session.getAuthToken());
    smr.addStringParam("document_password", "");
    smr.addStringParam("document_type","1");
    smr.addStringParam("document_subtype","1");
    smr.addStringParam("user_type", "b");
    smr.addStringParam("skip_kyd","no");
    smr.addStringParam("check_password","1");
    smr.addStringParam("total_files", "1");
    smr.addStringParam("file_name_prefix","file_upload");
    smr.addStringParam("is_pwd_array","no");
    smr.addStringParam("pwd_list_name", "document_password");
    smr.addStringParam("is_single_file","1");
    smr.addFile("file_upload",file.getAbsolutePath());

    /*Log.i("PanUploadRequest","Auth Token : "+session.getAuthToken()+" File Path : "+
            file.getAbsolutePath()+" Borrower Id : "+session.getBorrowerId());*/

    Log.i("PanUploadRequest", String.valueOf(smr.getMultipartParams()));

    RequestQueue mRequestQueue = Volley.newRequestQueue(AppController.getContext());
    mRequestQueue.add(smr);

1 个答案:

答案 0 :(得分:0)

您可以在将请求添加到队列之前编写以下代码:

VolleyLog.DEBUG = true;

完成调试后,请不要忘记删除此行。