Получение 409 Ошибка не может решить, как я могу решить - PullRequest
0 голосов
/ 04 февраля 2019

E / Volley: [19528] BasicNetwork.performRequest: Неожиданный код ответа 409 для http://13.232.142.23:3000/api/register

Я сделал предупреждение для обработки, если пользователь уже зарегистрирован и если otp неверенно во время регистрации это предупреждение не появляется, если ввод otp неверен или пользователь уже зарегистрирован.В чем проблема?я не могу его получить.

// registerUser (телефон, otp, полное имя, адрес электронной почты, пароль, идентификатор устройства);

    private void registerUser(final String phone,final String otp,final String fullname,final String email,  final String password, final String device_id )
    {

        Log.e(TAG, "otp12 " +otp11);

        String tag_string_req = "req_register";



        Map<String, String> params = new HashMap<String, String>();
        params.put("Content-Type", "application/json");



        params.put("phone",phone);
        params.put("otp",otp);
        params.put("fullname", fullname);
        params.put("email",email);


        params.put("password",password);

        params.put("device_id", device_id);

        JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.POST,
                AppConfig.Base_Url+AppConfig.App_api+AppConfig.URL_REGISTER, new JSONObject(params),
                new Response.Listener<JSONObject>()

 {

                  @Override
                    public void onResponse(JSONObject response1) {

                Log.d(TAG, "Register Response: " + response1.toString());


                try {
                    JSONObject jObj = new JSONObject(String.valueOf(response1));
                    String response = jObj.getString("code");
                    String status =jObj.getString("status");
                    String message= jObj.getString("message");

                    Log.e(TAG, "r2222" + response);
                    Log.e(TAG, "status1: " + status);
                    Log.e(TAG,"Message"+message);
                    if (status!=null && status.equals("true")) {

                        launchAgeScreen();

                        Log.e(TAG, "123" + fullname);
                        Log.e(TAG, "status: " + status);
                        Log.e(TAG, "paswword: " + password);

                        Log.e(TAG, "response2163123: " + response);

                    }else if (status!=null && message.equals("user is already register"))
                    {
                        AlertDialog.Builder builder =new AlertDialog.Builder(RegisterActivity.this);
                        builder.setTitle("Registration Error");
                        builder.setMessage("You have already registered with FeeDeposit. Please click Okay to Login");
                        builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                Intent intent = new Intent(RegisterActivity.this,LoginActivityWithoutSharedPreference.class);
                                startActivity(intent);
                            }
                        });
                        AlertDialog alertDialog = builder.create();
                        alertDialog.show();

                    }


                    else if (status!=null && message.equals("invalid otp"))
                    {

                        AlertDialog alertDialog = new AlertDialog.Builder(RegisterActivity.this, R.style.MyDialogTheme).create();

                        // Setting Dialog Title
                        alertDialog.setTitle("OTP ");

                        // Setting Dialog Message
                        alertDialog.setMessage("Invalid OTP");

                        // Setting Icon to Dialog
                        //  alertDialog.setIcon(R.drawable.tick);

                        // Setting OK Button
                        alertDialog.setButton("Okay", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                // Write your code here to execute after dialog closed
                                // Toast.makeText(getApplicationContext(), "You clicked on OK", Toast.LENGTH_SHORT).show();
                            }
                        });

                        alertDialog.show();

                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                    //Toast.makeText(getApplicationContext(), "Json error: " + e.getMessage(), Toast.LENGTH_LONG).show();
                }

            }
        }, new Response.ErrorListener() {

            @Override
            public void onErrorResponse(VolleyError error) {

                if (error instanceof TimeoutError || error instanceof NoConnectionError) {
                    AlertDialog alertDialog = new AlertDialog.Builder(RegisterActivity.this, R.style.MyDialogTheme).create();

                    // Setting Dialog Title
                    alertDialog.setTitle("Network/Connection Error");

                    // Setting Dialog Message
                    alertDialog.setMessage("Internet Connection is poor OR The Server is taking too long to respond.Please try again later.Thank you.");

                    // Setting Icon to Dialog
                    //  alertDialog.setIcon(R.drawable.tick);

                    // Setting OK Button
                    alertDialog.setButton("Okay", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            // Write your code here to execute after dialog closed
                            // Toast.makeText(getApplicationContext(), "You clicked on OK", Toast.LENGTH_SHORT).show();
                        }
                    });

                    // Showing Alert Message
                    alertDialog.show();
                   // Log.e(TAG, "Registration Error: " + error.getMessage());
                    /*Toast.makeText(context,
                            context.getString(R.string.error_network_timeout),
                            Toast.LENGTH_LONG).show();*/
                } /*else if (error instanceof AuthFailureError) {
                    //TODO
                } else if (error instanceof ServerError) {
                    //TODO
                } else if (error instanceof NetworkError) {
                    //TODO
                } else if (error instanceof ParseError) {
                    //TODO
                }
*/



            }
        }) /*{

            @Override
            protected Map<String, String> getParams() throws AuthFailureError{
                // Posting params to register url

                Map<String, String> params = new HashMap<String, String>();
                params.put("Content-Type", "application/json");



                params.put("phone",phone);
                params.put("otp",otp);
                params.put("fullname", fullname);
                params.put("email",email);


                params.put("password",password);

                params.put("device_id", device_id);




                return params;
            }

        }*/;






        jsonObjReq.setRetryPolicy(new DefaultRetryPolicy(
                MY_SOCKET_TIMEOUT_MS,
                DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));


        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
                && Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
            try {
                ProviderInstaller.installIfNeeded(getApplicationContext());
            } catch (GooglePlayServicesRepairableException e) {
                // Indicates that Google Play services is out of date, disabled, etc.
                // Prompt the user to install/update/enable Google Play services.
                GooglePlayServicesUtil.showErrorNotification(e.getConnectionStatusCode(), getApplicationContext());
                // Notify the SyncManager that a soft error occurred.
                //final SyncResult syncResult = null;
                //syncResult.stats.numIOExceptions++;

                //Toast.makeText(getApplicationContext(), "Sync", Toast.LENGTH_LONG).show();
                return;
            } catch (GooglePlayServicesNotAvailableException e) {
                // Indicates a non-recoverable error; the ProviderInstaller is not able
                // to install an up-to-date Provider.
                // Notify the SyncManager that a hard error occurred.
                //syncResult.stats.numAuthExceptions++;
               // Toast.makeText(getApplicationContext(), "Sync12", Toast.LENGTH_LONG).show();
                return;
            }

            HttpStack stack = null;
            try {
                stack = new HurlStack(null, new TLSSocketFactory());
            } catch (KeyManagementException e) {
                e.printStackTrace();
                Log.d("Your Wrapper Class", "Could not create new stack for TLS v1.2");
                stack = new HurlStack();
            } catch (NoSuchAlgorithmException e) {
                e.printStackTrace();
                Log.d("Your Wrapper Class", "Could not create new stack for TLS v1.2");
                stack = new HurlStack();
            }

             Appcontrol.getInstance().addToRequestQueue(jsonObjReq, tag_string_req);
           // AppController.getInstance().addToRequestQueue(getApplicationContext(),stack);

            requestQueue = Volley.newRequestQueue(getApplicationContext(), stack);
        } else {

            requestQueue = Volley.newRequestQueue(getApplicationContext());
            //AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
        }

        Appcontrol.getInstance().addToRequestQueue(jsonObjReq, tag_string_req);




        // Adding request to request queue
      //
        //
        //
        //
        //
        //AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
    }
...