This article describes how to avoid emojis in Python code output when using the Code Snippet connector. The same application can be applied to any playbook when an emoji is in the string and requires further action.
FortiSOAR.
In FortiSOAR Code Snippet is commonly used to process strings from logs or content from other connectors. In some cases, emoji may be present in the string especially for users from IOS or Android.
For this example, the Python code below is applied in Code Snippet:
As result, the error below will appear:
"500 Server Error: Internal Server Error for url: https://localhost:9595/integration/execute/?format=json :: \n<!doctype html>\n<html lang=\"en\">\n<head>\n <title>Server Error (500)</title>\n</head>\n<body>\n <h1>Server Error (500)</h1><p></p>\n</body>\n</html>\n"
To parse the emoji in the Jinja2 and JSON, additional lines below are required to escape ASCII characters:
print(json.dumps(test, ensure_ascii=False))
Successful results as below:
The Fortinet Security Fabric brings together the concepts of convergence and consolidation to provide comprehensive cybersecurity protection for all users, devices, and applications and across all network edges.
Copyright 2025 Fortinet, Inc. All Rights Reserved.