Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Path parameters being passed as a String with comma not read properly in rest assured

I have a code where I am passing path parameters in the GET request in Rest Assured. But I see the path parameters aren’t read properly and I see some gibberish text being read. Actually the String I am passing as path parameter contains a comma in it. Below is my code.

ValidatableResponse response = given().header("Authorization", token).header("Content-type", "application/json")
                .when().log().all().pathParam("CalendarId", testCaseBean.getCalendarId().toString())
                .queryParam("from", testCaseBean.getStartDate()).queryParam("to", testCaseBean.getEndDate())
                .queryParam("monthEnd", testCaseBean.getMonthEndBusinessDay())
                .get(EndPoint.GET_CALENDAR_BUSINESS_DAY_INFO_DATE_PARAM).then().log().all();

The path param I am passing is "AUS,EUR" and it is being read as AUS%2CEUR. I am passing this path parameter as test data from the CSV file. Below is the request being formed on the console.

https://portculation-qa.us-east-1.m5435454345.easn.mss.com/master-data/v1/calendars/AUS%2CEUR?from=2022-11-01&to=2022-11-01&monthEnd=false

My expected request URI is https://portculation-qa.us-east-1.m5435454345.easn.mss.com/master-data/v1/calendars/AUS,EUR?from=2022-11-01&to=2022-11-01&monthEnd=false

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You can see the only difference in the expected and actual URI is the gibberish path param which isn’t read properly. Any solution to tackle this issue?

>Solution :

Try adding this:

.urlEncodingEnabled(false)

RestAssured.given()
.contentType(JSON)
.log()
.all()
.urlEncodingEnabled(false)

or:

RestAssured.urlEncodingEnabled = false;

By default it set to true.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading