0

The okhttp is not storing cookies , the second request is on totally different values ​​of the desired , already tried in many ways , but I'm always getting new cookies with different values.

String url1 = "https://cadastro.saude.gov.br/cadsusweb/login.jsp";
            publishProgress("Definindo cookies");
            CookieManager cookieManager = new CookieManager();
            cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
            publishProgress("Definindo client");
            OkHttpClient client = new OkHttpClient.Builder()
                    .cookieJar(new JavaNetCookieJar(cookieManager))
                    .build();
            publishProgress("Requisição 1 - Fazendo requisição - GET");
            Request request = new Request.Builder()
                    .url(url1)
                    .build();
            client.newCall(request).enqueue(new Callback() {
                @Override
                public void onFailure(Call call, IOException e) {

                }

                @Override
                public void onResponse(Call call, Response response) throws IOException {
                    Headers headers = response.headers();
                    for (int i = 0; i < headers.size(); i++) {
                        txtHeaders += (headers.name(i) + ": " + headers.value(i))+"\n";
                    }

                }
            });



        } catch (Exception e) {
            e.printStackTrace();
        }
Leandro Campos
  • 330
  • 1
  • 3
  • 13

0 Answers0