Play Framework WS losing unicode chars from external api

♀尐吖头ヾ 提交于 2020-01-07 05:01:27

问题


I'm working on a play application that uses WS to make an asynchronous call to an external api and I can't figure out why I'm losing unicode chars when consuming

for instance if they api is producing something like:

   { "title": "Plück, Franke" }

and make a call to the api with:

ws.url("http://example.org/stuff/").get().map { response =>
  println(response.body)
  Ok....

The following will print:

{ "title":"Plück, Franke" }

I'm trying to find if there is a header argument that I need to be passing to the WSRequest object to preserve the character set? The WSRequest documentation for the setContentType method states

"Set the content type. If the request body is a String, and no charset parameter is included, then it will default to UTF-8."

What am I missing?

Thanks! AH


回答1:


This was a bug in the version of Play I was using (2.6.3) I upgraded to 2.6.7 and all was remedied.



来源:https://stackoverflow.com/questions/46456069/play-framework-ws-losing-unicode-chars-from-external-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!