Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

410
Visualizações
Get the url of a redirect with Rest Assured?

I am making a GET request which then makes a 307 redirect to another URL and from there it makes another 302 redirect and so on till it gets to the requested page. I am having problems extracting the URL from the first redirect, the 307, I want to see the location where is redirected to. I am using Rest Assured as framework. Thanks!

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I had the same problem, but I didn't have the 307, just 302. I imagine the solution would be the same. What I did was:

  1. stop following the redirects on the first call with redirects().follow(false)

  2. capture the URL from the first redirect

  3. make another call to follow the redirect(s)

    Response resp1 =
            given().
                contentType(ContentType.URLENC).
                body("AUTH_TOKEN=&j_username=" + encodedUsername + "&j_password=" + password + "&userName=&AUTH_TOKEN=").
                redirects().follow(false).
            expect().
                statusCode(302).
            when().
                post("/authenticate/j_spring_security_check");
    
    String headerLocationValue = resp1.getHeader("Location");
    
    Response resp2 =
            given().
                cookie(resp1.getDetailedCookie("JSESSIONID")).
            expect().
                statusCode(200).
            when().
                get(headerLocationValue);
    
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda