Results 1 to 9 of 9

Thread: Data encoding

  1. #1

    Default Data encoding

    Hi.

    Is there some setting to define the encoding when using the FaceBookTemplate.
    When I send data via FacebookTemplate.pubish the german umlauts (öäü...) get lost.

    If I use curl and encode the characters myself facebook displays them correctly:

    curl -F access_token=".." -F id=".." -F message="umlaute öäü" https://graph.facebook.com/feed

    So I guess this might be a RestTemplate issue.

  2. #2

    Default

    update from my side:

    After some investigation I found out that the RestTemplate uses StringHttpMessageConverter to convert the messages and this class has "ISO-8859-1" als default charset. This class does however analyze the content-type header for any charset settings but the facebook template class does not set any (at least I haven't found them).

    So I guess the solution would be for FacebookTemplate to set the charset of the content-type to UTF8 since this is what Facebook expects.

    I'll file a bug report for this.

  3. #3

    Default

    in the previous post I named the wrong converter. Since the request is a POST request the FormHttpMessageConverter is used.

    The bug report for this is under

    https://jira.springframework.org/browse/SPR-7789

  4. #4

    Default

    Hi,

    I'm having a similar issue and it is with the '+' sign. The service on the other side is interpreting the plus sign as a space which is correct, so I want my client using RESTTemplate to encode the '+' as %2B.

    How did you go about changing the encoding nitgate?

    /KramKroc

  5. #5

    Default

    My current workaround is to derive from the spring FacebookTemplate and modify the charset in the FormHttpMessageConverter.

    Code:
    for (HttpMessageConverter messageConverter : ((RestTemplate)restOperations).getMessageConverters()) {
    if (messageConverter instanceof FormHttpMessageConverter) {
    	FormHttpMessageConverter converter = (FormHttpMessageConverter)messageConverter;
    	converter.setCharset(Charset.forName("UTF8"));
    	}
    }
    But I quess this is not the right solution for you. A "+" should be encoded correctly by the current implementation. Could you give an example how you use the resttemplate?

  6. #6

    Default Still having problems with RestTemplate, FormHttpMessageConverter and UTF8 chars

    Has anyone been able to solve the encoding problem? I have done what was suggested and set the character encoding to UTF-8

    FormHttpMessageConverter c = new FormHttpMessageConverter();
    c.setCharset(Charset.forName("UTF-8"));
    restTemplate.getMessageConverters().add(c);

    But still when sending a post parameter

    MultiValueMap<String, Object> postParams = new LinkedMultiValueMap<String, Object>();
    postParams.add("name", "šěšě");

    On the receiving end I get ???? instead of šěšě. I have checked that the problem is not on the receiving end.

    cheers,
    Lili
    cheers,
    Lili

  7. #7

    Default

    BTW< I am using spring 3.0.4
    cheers,
    Lili

  8. #8

    Default

    lnader,

    please note that adding a new FormHttpMessageConverter will not solve this problem as there already is one in the list.

    Have a look at my code above. You have to change the charset of the FormHttpMessageConverter in the list.

    By looking at the jira issue I would say that this is solved in 3.0.6

  9. #9
    Join Date
    Aug 2004
    Posts
    1,072

    Default

    As nitegate pointed out, just adding another message converter won't do. You have to either modify the existing FormHttpMessageConverter or remove it and add a new (modified) one.

    Also, as was already pointed out, this has been fixed in Spring 3.0.6 and we encourage you to use that version of Spring with Spring Social. If you must use Spring 3.0.4, then you'll have to adjust the encoding yourself, as described above.
    Craig Walls
    Spring Social Project Lead

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •