public interface ApiInterface { @POST("?act=register") Call<RegResponse> register(@Query ("email") String email , @Query("fullname") String fullname , @Query("password") String password); } String name = mSignUpName.getText().toString(); String pass = mSignUpPasswordView.getText().toString(); email = mSignUpEmailView.getText().toString(); ApiInterface apiInterface = ApiClient.getClient().create(ApiInterface.class); Call<RegResponse> call = apiInterface.register(name,email,pass); call.enqueue(new Callback<RegResponse>() { @Override public void onResponse(Call<RegResponse> call, Response<RegResponse> response) { showProgress(false); Log.d("Log","True"); } @Override public void onFailure(Call<RegResponse> call, Throwable t) { showProgress(false); Log.d("Log","Error" + t.getMessage()); } }); |
1 answer
Do you want to send a POST or GET ? If POST , then @Query should use @RequestBody . If it's still GET , write how the query should look.
You can make it up like this:
RequestBody body = new FormBody.Builder() .add("email", email) .add("fullname", fullname) .add("password", password) .build(); - I have this api ..? act=register&email=test@gmail.com&fullname=Naka&password=123456 - Mr.Baga
- json {"info": [{"success": false, "object": "", "errors": ["\ u041f \ u043e \ u043b \ u044c \ u0437 \ u043e \ u0432 \ u0430 \ u0442 \ u0435 \ u043b \ u044c \ u0441 \ u0442 \ u0430 \ u043a \ u0438 \ u043c E-mail \ u0443 \ u0436 \ u0435 \ u0441 \ u0443 \ u0449 \ u0435 \ u0441 \ u0442 \ u0432 \ u0443 \ u0435 \ u0442 "]}]} -. Mr .Baga
- how to request a POST? - Mr.Baga
- then you should use
@POST-@GET- miha_dev instead of annotation - so @GET ("? act = register") Call <RegResponse> register (@Query ("fullname") String name, @ Query ("email") String email, @ Query ("password") String pass); - Mr.Baga
|