Rest API Enconding problem on OnAfterResponseAdvanced
Application Type
Service Studio Version
11.10.18 (Build 41211)
Platform Version

We are consuming some rest services and the returned data has accents and other special characters. We need the data encoded as UTF-8. Our rest APIs have the OnAfterResponseAdvanced set up in order to use some extensions. 

We configured the UTF-8 encoding using the BinaryDataToText action from the BinaryData extension inside the OnAfterResponseAdvanced in order to properly encode the returned data as UTF-8 as shown here. While debugging inside the  OnAfterResponseAdvanced the data is correctly encoded,  however, when leaving the OnAfterResponseAdvanced the data returns to its original encoding.

Any thoughts on why this happens and how could we overcome it.

Thanks in advance.

Hello @pvivacqua,

It would help with the troubleshooting if you could share a screenshot of your code with the properties of the 'BinaryDataToText' selected and another of the output variable is being set. Seems like it is just a simple miss somewhere in setting the output but hard to assess without a look at the actual code.



Hi Aj,

Thanks for the response. Following the screenshots:

Data before the BinaryDataToText action (OnAfterResponseAdvanced):

Data after the BinaryDataToText action (OnAfterResponseAdvanced):

Data arriving uncoded at the action after that call the Rest Web Service


What I think might be the case is that even after conversion, the Platform looks at the charset definition in the content-type header, or the lack thereof, and converts it back again. If the content arrives as UTF-8, but is taken to be ISO-8859-1, an "ã" is interpreted as "ã" (you can easily check that, for example, in Notepad++: paste the "ã", and select "ANSI" from the "Encoding" menu). When you convert it to UTF-8 it's right again (the "ã" is converted to "ã"), but then after the OnAfterResponse the content is intepreted again, and since the content-type header still indicates it's ISO-8859-1 (or at least lacks an indication it's UTF-8), it's converted back to "ã" again.

To solve this, see if you have a content-type header in the Header List, and change it to include UTF-8 (it should say "content-type:application/json;charset=utf-8").

Hi Kilian, thanks very much for your response. I tried the approaches for altering the Content-Type header but it did not work.

I altered the "Content-Type" header key directly on the extension that processes the output:

I also applied the encoding on the extension´s response:

Debugging the response on the OnAfterResponseAdvanced, the Content-Type is correctly configured:

However, the content is still coded incorrectly

Even if I format The Data with the BinaryDataToText action (OnAfterResponseAdvanced) it still goes arrives incorrectly on the service action. 

Any ideas?

Hi Kilian, just additional information, the action that calls the rest API is a service action. 


Hi pvivacqua.

Be sure to modify the CustomizedResponse Output Parameter after Response is assigned to it, not the original Response.

Hi Kilian, thanks very much for the response.

We are setting the CustomizedResponse Output Parameter with the encoded UTF-8. It seems that the action calling the rest api is not getting the changes.



Hi pvivacqua,

ResponseText and ResponseBinary should contain the same content, and in case you expect JSON, ResponseText should be used, not ResponseBinary. Converting the ResponseBinary to Text and assigning that to ResponseText isn't of much use. I'm not sure when the Platform uses ResponseText and when ResponseBinary, but they should always be the same, and ResponseText should already be UTF-8.

What I missed in your previous posts was that you use the OnAfterResponseAdvanced. Is there any reason for that? Are you using any additional processing? 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.