我知道它的重複的問題,但沒有得到他們的任何幫助,所以我問在這裏, 這些是我registeruser方法:凌空錯誤代碼400發生
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);
}
我凌空錯誤400,不知道有什麼問題,基本上是關於content-type
的錯誤,但正如我提到我的請求`內容類型和它以前的工作我做了服務器端的變化,並且API在postman bt中工作有問題在這裏。
我的堆棧跟蹤:
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
你可以發佈你的堆棧跟蹤嗎? – hsm59
我添加了堆棧跟蹤。 –
嘗試重寫「parseNetworkResponse(NetworkResponse響應)」以查看您的原始響應(也許它可以幫助你) –