0

I send some data to the data which includes a users details when the user wants to signup. I tried using Postman and the records are added successfully. Any post request i make returns Timeout but the data is still sent to the server. What could be the issue since i dont get any issues with my GET requests.

This is my API Service below:

@POST("/api/account/usersignup/")
@FormUrlEncoded
Call<LendingResponse> savePost(@Field("phoneNumber") String phoneNumber,
                    @Field("name") String name,
                    @Field("email") String email,
                    @Field("password") String password,
                    @Field("confirmPassword") String confirmPassword);

This is my method for saving invoking the API below:

public void sendPost(String userPhone, String userName, String userEmail, String userPassword, String userConfirmPassword) {


    final ProgressDialog loading = ProgressDialog.show(this, "Registering", "Please wait...", false, false);
    loading.show();

    mAPIService.savePost(userPhone, userName, userEmail, userPassword, userConfirmPassword).enqueue(new Callback<LendingAppResponse>() {
        @Override
        public void onResponse(Response<LendingAppResponse> response, Retrofit retrofit) {
            if(response.body().getSuccess().equals("true")) {
                Intent intent = new Intent(SignUpActivity.this, ValidatePhone.class);
                intent.putExtra("phone", userPhone);
                startActivity(intent);
                loading.dismiss();
            }
            else {
                String message = response.body().getMessage();
                Toast.makeText(SignUpActivity.this, message, Toast.LENGTH_LONG).show();
                loading.dismiss();
            }
        }

        @Override
        public void onFailure(Throwable throwable) {
            String error = throwable.getMessage();
            Toast.makeText(SignUpActivity.this, throwable.getMessage() + " Please try again", Toast.LENGTH_SHORT).show();
            loading.dismiss();
        }
    });
}

I have searched but can't seem to find any good solution.

Lending Square
  • 201
  • 1
  • 5
  • 14

1 Answers1

1

the solution: extending the time for timeout – by Lending Square

configuring a ReadTimeout and ConnectTimeout to to the httpClient an example:

   httpClient = new OkHttpClient();
   httpClient.setReadTimeout(60 * 1000, TimeUnit.MILLISECONDS);
   httpClient.setConnectTimeout(60 * 1000, TimeUnit.MILLISECONDS);
Gianluca Musa
  • 755
  • 7
  • 22
  • its still the same when i remove the backlash – Lending Square Jan 25 '18 at 11:27
  • when i use an HttpLoggingInterceptor this is the response 01-25 00:33:24.414 4272-4305/com.example D/OkHttp: --> POST /api/account/usersignup HTTP/1.1 01-25 00:33:24.414 4272-4305/com.example D/OkHttp: phoneNumber=6756435287&name=jonathanLa&email=joeyL%40g.com&password=chickenjoe&confirmPassword=chickenjoe 01-25 00:33:24.414 4272-4305/com.example D/OkHttp: --> END POST (105-byte body) – Lending Square Jan 25 '18 at 11:40
  • 1
    it is via Post. i found a solution by extending the time for timeout – Lending Square Jan 25 '18 at 12:11