user1684462
user1684462

Reputation:

JAVA Rest-Assured DSL redirects not working

I am trying to configure my rest-assured tests to ignore redirects by using the following code:

RestAssured.config = config().redirect(redirectConfig().followRedirects(true).and().maxRedirects(20));

Rest-Assured DSL

I am doing a PUT on a REST service and I get 302 HTML back because of the redirects, instead of the expected JSON type. Has anyone gotten this to work another away with rest-assured ? Let me know if you need more info

Upvotes: 4

Views: 3183

Answers (2)

Ivanna
Ivanna

Reputation: 21

Try using SessionId to omit redirection, this is what helped me:

String sessionId = RestAssured.given().auth().preemptive().basic("user", "password").when().post("/x").andReturn().sessionId(); RestAssured.given().sessionId(sessionId).

Upvotes: 0

user1684462
user1684462

Reputation:

Jayway Link

The above link explains that POST/PUT should get a response of a 303 instead of 302, and since I am getting a 302 on a PUT, rest assured does not support redirects for that. If I do GET and receive a 302, all is well.

Upvotes: 3

Related Questions