BasicNetwork.performRequest:截击请求中意外的响应代码500

时间:2019-10-15 19:24:30

标签: java android android-volley

我有一个页面,用于通过截击将用户的数据发送到服务器,该方法是post(它也可与patch一起使用),并且我想将用户输入的信息发送到服务器,但是我出错了,并且可以正常使用邮递员中的相同数据。

您知道我应该将数据作为参数发送。

这是我的功能:

     public void Update()
{

    final String tagsssss = "sdkjfskjdfhksd";

    final String url = "https://parastoo.app/api/update-get-driver-info";



    String token = G.getString("token");
    String name = formEdtName.getText().toString();
    String smartNum = formEdtSmartNum.getText().toString();
    String sheba = formEdtSheba.getText().toString();
    String code = formEdtCode.getText().toString();
    String driverDebitNumber = formEdtBank.getText().toString();

    Double lat = G.getDouble("latitude", 0);
    Double lng = G.getDouble("longitude", 0);

    String latitude = String.valueOf(lat);
    String longitude = String.valueOf(lng);


    String imageData = imagToString(bitmap);
    String phoneNum = G.getString("phonenumber");


    Toast.makeText(getApplicationContext(), "Start", Toast.LENGTH_SHORT).show();


    Response.Listener<JSONObject> listener = new Response.Listener<JSONObject>()
    {
        @Override
        public void onResponse(JSONObject response)
        {
            startActivity(new Intent(RegisterActivity.this, VerifiedRegisterActivity.class));

            Log.i(tagsssss, "Success");
            Log.i(tagsssss, response.toString());
        }
    };

    Response.ErrorListener errorListener = new Response.ErrorListener()
    {
        @Override
        public void onErrorResponse(VolleyError error)
        {
            Log.e(tagsssss, error.toString());
            //Log.e(tagsssss, error.getCause().toString());
            error.printStackTrace();
        }
    };

    JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, url, listener, errorListener)
    {


        @Override
        public Map<String, String> getParams() throws AuthFailureError
        {
            Map<String, String> params = new HashMap<String, String>();

            params.put("driverPhoneNumber", phoneNum);
            params.put("driverSmartNumber", smartNum);
            params.put("driverNationalCode", code);
            params.put("latitude", latitude);
            params.put("longitude", longitude);
            params.put("driverIbanNumber", sheba);
            params.put("driverFailureRate", null);
            params.put("driverActive", null);
            params.put("driverDebitNumber", driverDebitNumber);
            params.put("driverFullName", name);
        //    params.put("avatar_url", imageData);
            params.put("token", token);
            return params;
        }

        @Override
        public Map<String, String> getHeaders() throws AuthFailureError
        {
            Map<String, String> headers = new HashMap<String, String>();
            headers.put("Content-Type", "multipart/form-data");
            return headers;
        }

    };

    final int socketTimeout = 100000;
    RetryPolicy policy = new DefaultRetryPolicy(socketTimeout, 0, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
    request.setRetryPolicy(policy);

    AppSingleton.getInstance(getApplicationContext()).addToRequestQueue(request);
}

0 个答案:

没有答案