Rest-Assured : By-passing Charset in the Request?

2,520 views
Skip to first unread message

Atindriyo Sanyal

unread,
Aug 30, 2013, 10:28:07 AM8/30/13
to rest-a...@googlegroups.com
Hi there,

I'm calling an API (that I don't have the source code to) using rest-assured. I specify "application/x-www-form-urlencoded" as the content-type of the Request. But rest-assured appends the Charset to this content-type in the request.

So my request looks like this:
"Content-Type: application/x-www-form-urlencoded; charset=ISO-8859-1"


I know that ISO-8859-1 is a standard HTTP charset, but the API that I call is unable to process this.
Removing the charset part (Content-Type: application/x-www-form-urlencoded) gives me a 200 OK (I CURLed this).

I want to know, is there any way that I can exclude the "charset" in the request that I make through rest-assured? Just so that the External API doesn't get affected.

Thanks for the help in advance.

Regards,
Atindriyo

Johan Haleby

unread,
Aug 31, 2013, 9:33:19 AM8/31/13
to rest-a...@googlegroups.com
Hi, 

Do you know what charset the server is excepting? Perhaps you could just change the charset to that? For example changing the charset to UTF-8 for all requests can be done like this:

RestAssured.config = new RestAssuredConfig().encoderConfig(encoderConfig().defaultContentCharset("UTF-8"))

Regards,
/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/groups/opt_out.

canpan14

unread,
Dec 20, 2016, 3:41:13 PM12/20/16
to REST assured
In case anyone runs else runs into this. There is a method called 'appendDefaultContentCharsetToContentTypeIfUndefined' used to fix this exact issue.

RestAssured.config = RestAssured.config().encoderConfig(encoderConfig().appendDefaultContentCharsetToContentTypeIfUndefined(false));
Reply all
Reply to author
Forward
0 new messages