POST request in retrofit2

Asked

Viewed 72 times

1

How do I send data from a form on android using retrofit2? The way I am doing the information stored in the database is being sent through a passage per parameter, I would like to recover the data from an Edittext for example, someone can help me?

Below is my code using retrofit2:

> Call<Usuario> call = usuarioAPI.criaUsuario(new
> Usuario("login","senha","nome"));
>     call.enqueue(new Callback<Usuario>() {
>         @Override
>         public void onResponse(Response<Usuario> response, Retrofit retrofit) {
> 
>             if (!response.isSuccess()) {
>                 response.body().getLogin();
>                 Log.i("TAG", "POST Erro: " + response.code());
>             } else {
>                 Log.i("TAG", "POST Sucesso: " + response.code());
>             }
>         }
> 
>             @Override
>             public void onFailure(Throwable t) {
>                 Log.i("TAG", "Erro no método onFailure: " + t.getMessage());
>             }
>     });
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.