排球错误代码400

时间:2017-09-15 07:10:48

标签: android android-volley

我知道它的重复问题,但没有得到任何帮助,所以我在这里问,  这些是我的registeruser方法:

 private void registerUser(final String name, final String phone_email, final String password) throws JSONException {
    Log.d(TAG,name +" "+ phone_email +" "+ password);
    // Tag used to cancel the request
    String tag_string_req = "req_register";

    pDialog.setMessage("Registering ...");
    showDialog();

    JSONObject jobj= new JSONObject();
    try {
            jobj.put("name", name);
            jobj.put("email ", phone_email);
            jobj.put("password", password);
    }catch (JSONException e) {
        e.printStackTrace();
    }

    JsonObjectRequest jsonReq = new JsonObjectRequest(Request.Method.POST,AppConfig.URL_SEND_OTP,
    jobj, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            Log.d(TAG, response.toString() + "Registration responce");
            hideDialog();
            Intent otp = new Intent(getApplicationContext(), 
                                      OTPActivity.class);
            otp.putExtra("name",user_name);
            otp.putExtra("phone",user_phone_email);
            startActivity(otp);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            VolleyLog.d(TAG, "Error: " + error.getMessage());
            hideDialog();
        }
    }) {
        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            HashMap<String, String> headers = new HashMap<String, String>();
            headers.put("Content-Type", "application/json; charset=utf-8");
            return headers;
        }
    };
    // Adding request to request queue
    Log.e("responce string",jsonReq.toString());
    AppController.getInstance(this).addToRequestQueue(jsonReq,tag_string_req);
}

我得到Volley错误400,不知道是什么问题,基本上是关于content-type错误,但正如我提到我的请求`内容类型及其以前的工作bt我在服务器端和API中做了更改正在邮递员工作,这里有问题。

我的堆栈跟踪:

    09-15 12:49:33.767 22856-22856/com.wowoni.bikesharing.bicyclesharing D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{6ae5f97 V.E...... R.....I. 0,0-0,0}
09-15 12:49:33.797 22856-22856/com.wowoni.bikesharing.bicyclesharing E/responce string: [ ] http://192.168.43.187:8085/send-otp 0x37295400 NORMAL null
09-15 12:49:33.857 22856-24436/com.wowoni.bikesharing.bicyclesharing I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
09-15 12:49:33.857 22856-24436/com.wowoni.bikesharing.bicyclesharing I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
09-15 12:49:33.867 22856-24436/com.wowoni.bikesharing.bicyclesharing I/qtaguid: Tagging socket 49 with tag 3729540000000000{925455360,0} uid -1, pid: 22856, getuid(): 10443
09-15 12:49:33.887 22856-23046/com.wowoni.bikesharing.bicyclesharing D/mali_winsys: new_window_surface returns 0x3000,  [796x360]-format:1
09-15 12:49:33.977 22856-22856/com.wowoni.bikesharing.bicyclesharing D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
09-15 12:49:36.377 22856-24436/com.wowoni.bikesharing.bicyclesharing I/qtaguid: Untagging socket 49
09-15 12:49:36.377 22856-24436/com.wowoni.bikesharing.bicyclesharing I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
09-15 12:49:36.377 22856-24436/com.wowoni.bikesharing.bicyclesharing I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
09-15 12:49:36.387 22856-24436/com.wowoni.bikesharing.bicyclesharing I/qtaguid: Tagging socket 49 with tag 3729540000000000{925455360,0} uid -1, pid: 22856, getuid(): 10443
09-15 12:49:36.777 22856-24436/com.wowoni.bikesharing.bicyclesharing I/qtaguid: Untagging socket 49
09-15 12:49:36.787 22856-24436/com.wowoni.bikesharing.bicyclesharing E/Volley: [59688] BasicNetwork.performRequest: Unexpected response code 400 for http://192.168.43.187:8085/send-otp
09-15 12:49:36.797 22856-22856/com.wowoni.bikesharing.bicyclesharing D/Volley: [1] 2.onErrorResponse: RegistorActivity
09-15 12:49:36.807 22856-22856/com.wowoni.bikesharing.bicyclesharing D/ViewRootImpl: #3 mView = null
09-15 12:49:36.827 22856-22856/com.wowoni.bikesharing.bicyclesharing E/ViewRootImpl: sendUserActionEvent() mView == null
09-15 12:49:39.277 22856-22856/com.wowoni.bikesharing.bicyclesharing D/ViewRootImpl: ViewPostImeInputStage processPointer 0
09-15 12:49:39.427 22856-22856/com.wowoni.bikesharing.bicyclesharing D/ViewRootImpl: ViewPostImeInputStage processPointer 1

1 个答案:

答案 0 :(得分:0)

Volley对jsonObjectRequest不太满意。一次请尝试使用Retrofit。它肯定会解决您的问题。我也有这个问题由Retrofit解决。

相关问题