Skip to content

Commit

Permalink
Merge pull request #1511 from mohanachandran-s/develop
Browse files Browse the repository at this point in the history
MOSIP-34152
  • Loading branch information
Sohandey authored Jul 1, 2024
2 parents e5ea27b + 2de49c5 commit a27aa1f
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import io.mosip.testrig.apirig.testrunner.MosipTestRunner;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.config.HttpClientConfig;
import io.restassured.config.RestAssuredConfig;
import io.restassured.http.Cookie;
Expand Down Expand Up @@ -1763,4 +1764,24 @@ public static Response postRequestWithQueryParamBodyAndCookie(String url, Object

return postResponse;
}
}

public static byte[] postRequestWithFormDataBodyForPdf(String url, Map<String, String> formData) {
byte[] pdf;
GlobalMethods.addToServerEndPointMap(url);

EncoderConfig encoderConfig = new EncoderConfig().encodeContentTypeAs("application/x-www-form-urlencoded",
io.restassured.http.ContentType.URLENC);
RESTCLIENT_LOGGER.info("REST-ASSURED: Sending a POST request to " + url);

if (ConfigManager.IsDebugEnabled()) {
pdf = given().config(config.encoderConfig(encoderConfig)).relaxedHTTPSValidation().formParams(formData)
.contentType("application/x-www-form-urlencoded").log().all().when().post(url).then().extract()
.asByteArray();
} else {
pdf = given().config(config.encoderConfig(encoderConfig)).relaxedHTTPSValidation().formParams(formData)
.contentType("application/x-www-form-urlencoded").when().post(url).then().extract().asByteArray();
}

return pdf;
}
}

0 comments on commit a27aa1f

Please sign in to comment.