Consume REST API Encoding problem | DeepL Rest API
Service Studio Version
11.11.6 (Build 44614)
Platform Version
11.12.1 (Build 30548)

Hello Internet

I've been trying to connect the DeepL REST API for two days now and I'm failing with the "encoding". As you can see on this DemoPage (OML attached):

https://personal-wlfdncte.outsystemscloud.com/DeepLDemo/DeepL


texts e.g. to Greek, Chinese or Japanese are not translated correctly but only converted into a mess of numbers and characters. I have read various forum entries and tried to take them into account. Unfortunately it did not work or I did something wrong.

Would be great if you could show me my mistake.

Kind regards

Daniel

PS: DeepLAPI Key is included. Will change it after a solution is found.

LINKS:


DeepLDemo.oml

Solution

Hi Daniel,

Please find attached the solution require to handle the encoding correctly, all required logic in OnAfterResponse:



To deal with the Japanese characters correctly we need to deal with the encoding, consumed service is not defining "Content-Type" header with "charset=utf-8" (example response in postman):


I created a new TEST page and a new REST reference ApifreeDeepl2 to deal with this.

This page also helps http://string-functions.com/encodedecode.aspx to deal with encodings:

What's happing is that OutSystems when consumes a rest api and the charset is not specified we use default encoding specified in the rfc of the http definition that is iso-8859-1, in this case we need to force to use the utf-8 in the way described attached.

Hope this helps you!

DeepLDemo.oml

mvp_badge
MVP

Hi Daniel,

Thanks for this great answer, I hope the OP can solve their problem now. However, I noticed the first image in your post is broken, perhaps you can try to fix that? Thanks!

Image fixed! Thank you for your feedback.

Thanks, works perfect!

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