Special Character encoding using UTF-8 not happening...

1,836 views
Skip to first unread message

Chandru

unread,
Nov 5, 2015, 4:16:43 AM11/5/15
to REST assured
Hello,

      I have a string 'äöü߀’ ' (German) which is one of the attribute in json object. when I hit the url  using RestAssured API, above mentioned string is encoded as "äöü߀’" . I assume this is 'ISO-8859-1' encoding but i would want UTF-8 encoding. I read in 'Restassured documentation' that Encoding will use Jackson or GSon if they are in classpath otherwise exception will be thrown. However i found out  Restassured is not throwing any exception instead using groovy-JSON' for encoding which is in dependent library list of Restassured. Could you please let us know how do we encode using UTF-8 charset ?

 RestAssured.given().request().contentType("application/json;charset=utf-8").log().all().body(object).post(URL);




Thanks
Chandru

Johan Haleby

unread,
Nov 5, 2015, 4:20:06 AM11/5/15
to rest-a...@googlegroups.com
Thanks for pointing this out. Could you add an issue that I should document the use of "Groovy JSON"? So is the object mapper being used in your example Groovy JSON? What happens if you use GSON or jackson/jackson2 instead? Specifying the charset in the content-type like you do should work. Also which version of REST Assured are you using?

--
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/d/optout.

Chandru

unread,
Nov 5, 2015, 4:39:13 AM11/5/15
to REST assured
Thanks for the quick reply.
  I tried using both 2.4.0 and latest 2.7.0.  The fact is RestAssured jar depends on Groovy and groovy-json jars. In my example, iam not using groovy. I only use Restassured jar to test my Rest APIs. It works fine if i use normal string without any special characters.(Ex: ' projectName'). as part of the object.

Thanks
Chandru

Chandru

unread,
Nov 5, 2015, 6:43:39 AM11/5/15
to REST assured
 I tried with ObjectMapperType and i got 'not in classpath' issue if the jackson jars are not available in classpath. Even after putting them in classpath, i have the same 'ISO-8859-1' encoding issue instead of UTF-8 encoding.

RestAssured.given().request().contentType(ContentType.JSON).log().all().body(object1,ObjectMapperType.JACKSON_2).post(URLPREFIX + PROJECTURL);

Johan Haleby

unread,
Nov 5, 2015, 2:06:11 PM11/5/15
to rest-a...@googlegroups.com
I saw that you created an issue and I'll try to look into it soon
Reply all
Reply to author
Forward
0 new messages