Special characters (such as the £ British Pound [GBP] currency character) as they are read from the database in a GEL script that uses the REST API to write the content into a String attribute leads to unexpected characters (<?> symbol).
If the string contains a newline (non-printable character), the REST API fails completely returning a 400 error.
Steps to Reproduce
my_string1 and my_string2) and enable them in the MUX (z_my_string1 and z_mystring_2).my_string2 with the read value.my_string2.Expected Results: my_string2 displays '£ GBP'.
Actual Results: my_string2 displays '<?> GBP' ('<?>' is a single, special character)
[newline]GBP' ('[newline]' is a new line with enter key, not actual text)Expected Results: my_string2 displays '£ GBP[newline]GBP'.
Actual Results: REST API request fails with an error 400.
For the first scenario (£ GBP), specify the correct charset. Example fragment of code:
<core:set var="createProject" encode="0" escapeText="true">{"z_my_string2": "${my_string1}"}</core:set> <core:new var="entity" className="org.apache.http.entity.StringEntity"> <core:arg value="${createProject}" type="java.lang.String" /> <core:arg value="UTF-8" type="java.lang.String" /> </core:new>
For the second scenario (£ GBP[newline]GBP), before making the API call the payload needs to be escaped as the control characters are being used in the payload. Example fragment of code:
<core:invokeStatic className="org.apache.commons.text.StringEscapeUtils" method="escapeJson" var="escaped_my_string1"> <core:arg value="${my_string1}" type="java.lang.String"/> </core:invokeStatic>
[...]
<core:set var="createProject" encode="0" escapeText="true">{"z_my_string2": "${escaped_my_string1}"}</core:set>