search cancel

CA API Gateway - Problem with javascript assertion replaces Special Characters (umlaut) with '?' symbol in api gateway 9.4


Article ID: 199558


Updated On:


CA API Gateway API SECURITY CA API Gateway Precision API Monitoring Module for API Gateway (Layer 7) CA API Gateway Enterprise Service Manager (Layer 7) STARTER PACK-7 CA Microgateway


We are facing problems when using the following function inside the "Execute Javascript assertion":
  resp1 = context.getOrCreateMessageVariable ('request');
  requestBody = resp1.getContent();

When there are special characters in the payload like accents or 'ñ'; it automatically replaces them with the '?' symbol. 
We need to make transformation with the different payloads allowing special characters and not replacing it with '?' characters. Can you help us?

You can try with this payload:

"Description""Updated Description.",
"Name""Updated Organización Test",

And you will get the following result:
"Description""Updated Description.",
"Name""Updated Organizaci?n Test",


Release : 9.4

Component : API GATEWAY


The solution is to add Content-Type header with value "application/json" when sending the request.

When the Content-Type header is application/json, I can see the special characters correctly. I tried with the payload in the description and the longer payload in one of the comments

If you send something like Content-Type: text/plain, you will see the question marks

Above solution didn't seem to work in this use case scenario; however, add Content-Type header with value "application/javascript" and it worked!


1. Add LANG environment variable when starting the container gateway: LANG=en_US.UTF-8 (docker-compose for example has a way to define environment variables in docker-compose file)

  - This should start the container gateway with the en_US.UTF-8 locale instead of POSIX

2. Use Content-Type application/json