Rest-Assured doesn't redirect post-requests

Skip to first unread message

Harshal Chopade

Mar 25, 2022, 4:11:27 AMMar 25
to REST assured
Hi All,

I have a question if anyone has any experience the below issue with redirect post-requests

I am trying to hit an post API using Rest-Assured.

The same API hit (with same header data) works fine from Postman but while hitting the request from Rest-Assured, I always receive following response:

307 Temporary Redirect

Below is the method am using

public Response post(String path, HashMap<String, String> headers, String payload, int statusCode,
HashMap<String, String> validations) throws Exception {
String contentType = "";
if (headers.get("Content-Type") != null) {
contentType = headers.get("Content-Type");
} else if (headers.get("content-type") != null) {
contentType = headers.get("content-type");
Response returnResponse;
returnResponse = given()
.encoderConfig(new EncoderConfig().appendDefaultContentCharsetToContentTypeIfUndefined(false)))
.relaxedHTTPSValidation().contentType(contentType).filter(new RestAssuredRequestFilter())
.headers(headers).body(payload).post(host + path);
return returnResponse;

If you have a solution or experience feel free to suggest

Reply all
Reply to author
0 new messages