GET request 302 URL redirection

461 views
Skip to first unread message

Saurabh Garg

unread,
Jul 12, 2018, 6:37:05 AM7/12/18
to REST assured
How to handle 302 GET request URL redirection?

There is a URL when I enter that in a browser it redirects to another URL and give the JSON response but when I hit the first URL through rest assured it gives 401 Authorization error.

How to handle such scenario

Saurabh Garg

unread,
Jul 12, 2018, 6:41:10 AM7/12/18
to REST assured
one way, which I found is like make the redirection false and get the value of the cookie and pass it into redirected URL(URL2) to get the response but in above case, we have to hit two request.

Is there any way where we can get the response by hitting only first URL?

Johan Haleby

unread,
Jul 13, 2018, 6:51:48 AM7/13/18
to rest-a...@googlegroups.com
Depends on which HTTP method you're using. REST Assured (thanks to apache http client) automatically follows redirects if instructed to do so for GET requests. In other cases (see for example https://blog.jayway.com/2012/10/17/what-you-may-not-know-about-http-redirects/) you may need to extract the Location header manually and make a new request.

/Johan



--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages