Skip to main content
Pergunta fechada como "Não é adequada para este site" por Syzoth, hugocsl, renanvm, Darlei Fernando Zillmer, Augusto Vasques
adicionou 68 caracteres ao conteúdo
Fonte Link
D/OkHttp: --> POST https://APIinoprime.com.br/api/login/
D/OkHttp: Content-Type: application/json
    Accept: application/json
    Content-Length: 61
D/OkHttp: {"email":"EMAIL","password":"****"}
    --> END POST (60-byte body)
D/OkHttp: <-- 400 https://APIinoprime.com.br/api/login/ (2130ms)
    server: awselb/2.0
    date: Wed, 15 Jan 2020 14:36:31 GMT
    content-type: text/html
    content-length: 138
D/OkHttp: <html>
    <head><title>400 Bad Request</title></head>
    <body bgcolor="white">
    <center><h1>400 Bad Request</h1></center>
    </body>
    </html>
    <-- END HTTP (138-byte body)
Accept: application/json
Content-Type: application/json
cookie: COOKIE
content-length: 61
POST https://inoprime.com.br/api/login/ HTTP/1.1
Host: HOST
Accept: application/json
Content-Type: application/json
cookie: COOKIE
content-length: 61

 {"email":"EMAIL","password":"***"}
D/OkHttp: --> POST https://API/
D/OkHttp: Content-Type: application/json
    Accept: application/json
    Content-Length: 61
D/OkHttp: {"email":"EMAIL","password":"****"}
    --> END POST (60-byte body)
D/OkHttp: <-- 400 https://API (2130ms)
    server: awselb/2.0
    date: Wed, 15 Jan 2020 14:36:31 GMT
    content-type: text/html
    content-length: 138
D/OkHttp: <html>
    <head><title>400 Bad Request</title></head>
    <body bgcolor="white">
    <center><h1>400 Bad Request</h1></center>
    </body>
    </html>
    <-- END HTTP (138-byte body)
Accept: application/json
Content-Type: application/json
cookie: COOKIE
content-length: 61
POST /api/login/ HTTP/1.1
Host: HOST
Accept: application/json
Content-Type: application/json
cookie: COOKIE
content-length: 61

 {"email":"EMAIL","password":"***"}
D/OkHttp: --> POST https://inoprime.com.br/api/login/
D/OkHttp: Content-Type: application/json
    Accept: application/json
    Content-Length: 61
D/OkHttp: {"email":"EMAIL","password":"****"}
    --> END POST (60-byte body)
D/OkHttp: <-- 400 https://inoprime.com.br/api/login/ (2130ms)
    server: awselb/2.0
    date: Wed, 15 Jan 2020 14:36:31 GMT
    content-type: text/html
    content-length: 138
D/OkHttp: <html>
    <head><title>400 Bad Request</title></head>
    <body bgcolor="white">
    <center><h1>400 Bad Request</h1></center>
    </body>
    </html>
    <-- END HTTP (138-byte body)
Accept: application/json
Content-Type: application/json
cookie: COOKIE
content-length: 61
POST https://inoprime.com.br/api/login/ HTTP/1.1
Host: HOST
Accept: application/json
Content-Type: application/json
cookie: COOKIE
content-length: 61

 {"email":"EMAIL","password":"***"}
Alteração sugeria pelo Guilherme e Ricardo
Fonte Link
@Headers({
        "Content-Type: application/json",
        "Accept: application/json",
})
@POST(Constants.API_LOGIN)
Call<Login> login(@Body Credentials credential);

Credentials

public class Credentials {

    // "Content-Length:Atributos
 61"   private String email;
    private String password;

    // GETs e SETs
    // Email
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
@POST        this.email = email;
    }

    // Password
    public String getPassword(Constants) {
        return password;
    }

    public void setPassword(String password) {
        this.API_LOGINpassword = password;
    }

    // Metodos
    @NonNull
    @Override
    public String toString() {
Call<Login> login       return "{\"email\":\"" + getEmail(@Body) JsonObject+ json"\", \"password\":\"" + getPassword(); + "\"}";
    }

}

//        JsonObject json = new JsonObject();
//        json.addProperty("email", AUTH_USER);
//        json.addProperty("password", AUTH_PASS);
        Credentials credential = new Credentials();
        credential.setEmail(AUTH_USER);
        credential.setPassword(AUTH_PASS);

        Call<Login> call = new RetrofitConfig().getLoginService().login(jsoncredential);
        call.enqueue(new Callback<Login>() {
            @Override
            public void onResponse(@NonNull Call<Login> call, @NonNull Response<Login> response) {
                Login login = response.body();
                Log.d(TAG, "RESPONSE: " + response.message());
                String msg = "Autenticado com sucesso.";
            }

            @Override
            public void onFailure(@NonNull Call<Login> call, @NonNull Throwable t) {
                Log.e(TAG, "Error: " + t.getMessage(), t);
                Toast.makeText(context, "Erro ao autenticar com servidor", Toast.LENGTH_SHORT).show();
                call.cancel();
            }

        });
@Headers({
        "Content-Type: application/json",
        "Accept: application/json",
        "Content-Length: 61"
})
@POST(Constants.API_LOGIN)
Call<Login> login(@Body JsonObject json);
        JsonObject json = new JsonObject();
        json.addProperty("email", AUTH_USER);
        json.addProperty("password", AUTH_PASS);

        Call<Login> call = new RetrofitConfig().getLoginService().login(json);
        call.enqueue(new Callback<Login>() {
            @Override
            public void onResponse(@NonNull Call<Login> call, @NonNull Response<Login> response) {
                Login login = response.body();
                Log.d(TAG, "RESPONSE: " + response.message());
                String msg = "Autenticado com sucesso.";
            }

            @Override
            public void onFailure(@NonNull Call<Login> call, @NonNull Throwable t) {
                Log.e(TAG, "Error: " + t.getMessage(), t);
                Toast.makeText(context, "Erro ao autenticar com servidor", Toast.LENGTH_SHORT).show();
                call.cancel();
            }

        });
@Headers({
        "Content-Type: application/json",
        "Accept: application/json"
})
@POST(Constants.API_LOGIN)
Call<Login> login(@Body Credentials credential);

Credentials

public class Credentials {

    // Atributos
    private String email;
    private String password;

    // GETs e SETs
    // Email
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    // Password
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    // Metodos
    @NonNull
    @Override
    public String toString() {
        return "{\"email\":\"" + getEmail() + "\", \"password\":\"" + getPassword() + "\"}";
    }

}

//        JsonObject json = new JsonObject();
//        json.addProperty("email", AUTH_USER);
//        json.addProperty("password", AUTH_PASS);
        Credentials credential = new Credentials();
        credential.setEmail(AUTH_USER);
        credential.setPassword(AUTH_PASS);

        Call<Login> call = new RetrofitConfig().getLoginService().login(credential);
        call.enqueue(new Callback<Login>() {
            @Override
            public void onResponse(@NonNull Call<Login> call, @NonNull Response<Login> response) {
                Login login = response.body();
                Log.d(TAG, "RESPONSE: " + response.message());
                String msg = "Autenticado com sucesso.";
            }

            @Override
            public void onFailure(@NonNull Call<Login> call, @NonNull Throwable t) {
                Log.e(TAG, "Error: " + t.getMessage(), t);
                Toast.makeText(context, "Erro ao autenticar com servidor", Toast.LENGTH_SHORT).show();
                call.cancel();
            }

        });
Imagens para exemplificar como foi feita a requisição no ARC
Fonte Link

Dados do ARC Preenchimento dos dados da requisição no ARC

Retorno do ARC inserir a descrição da imagem aqui

LOG do ARC inserir a descrição da imagem aqui

Alguém consegue me ajudar?

Alguém consegue me ajudar?

Dados do ARC Preenchimento dos dados da requisição no ARC

Retorno do ARC inserir a descrição da imagem aqui

LOG do ARC inserir a descrição da imagem aqui

Alguém consegue me ajudar?

Fonte Link
Carregando