retrofit 2 error malformed when sending a post

0

When I send the data via POST, I return that JSON is in formation error. Follows the% w / w of the

 Button btnretrofit =(Button)findViewById(R.id.btnretofit);
    btnretrofit.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            String nome = Nome.getText().toString();
            String dataNascimento = DataNascimento.getText().toString();
            String cell = Cell.getText().toString();
            String Email = email.getText().toString();
            String Sobrenome = sobrenome.getText().toString();


            APIServices apiservice = retrofit.create(APIServices.class);

            Call<User> call = apiservice.createUser(nome,dataNascimento,cell,Email,Sobrenome);

            call.enqueue(new Callback<User>() {
                @Override
                public void onResponse(Call<User> call, Response<User> response) {

                    if(response.isSuccessful()){
                        Toast.makeText(getApplicationContext(),"sucesso"+ response.code(), Toast.LENGTH_LONG).show();
                    }else{

                        Toast.makeText(getApplicationContext(),"Erro a conectar ao servidot"+ response.code(), Toast.LENGTH_LONG).show();
                    }

                }

                @Override
                public void onFailure(Call<User> call, Throwable t) {

                    Toast.makeText(getApplicationContext(),"Erro a conectar ao servidot"+ t.getMessage(), Toast.LENGTH_LONG).show();

                }
            });

        }
    });

In my api follows the code

@FormUrlEncoded
@POST("/gson/insertData.php")
Call<User>  createUser(
        @Field("Nome")String nome,
        @Field("DataNascimento") String dataNascimento,
        @Field("Cell") String cell,
        @Field("email") String Email,
        @Field("Sobrenome") String Sobrenome
);

In my class

public class User {
    private Integer IdUsuario;

    private String nome;
    private String cell;
    private String DataNascimento;
    private String email;
    private String Sobrenome;


    public User( String nome, String dataNascimento, String cell,  String email, String Sobrenome ) {
        this.nome = nome;
        this.cell = cell;
        this.DataNascimento = dataNascimento;
        this.email = email;
        this.Sobrenome = Sobrenome;
    }

    public Integer getIUsuario() {
        return IdUsuario;
    }
}
    
asked by anonymous 20.05.2017 / 20:01

1 answer

0

Personal the resolution of the posted difficulty was to insert in the code below the line .setLenient ()

Gson gson = new GsonBuilder ()             .setDateFormat ("yyyy-MM-dd'T'HH: mm: ssZ")             .setLenient ()             .create ();

    
23.05.2017 / 15:28