Context:
We are attempting to synchronize Quality Management (QM) evaluation results from Genesys Cloud to our ServiceNow instance using the Data Actions framework. The objective is to update the cmdb_ci_service table with specific quality metrics for a given interaction ID, ensuring that service health records reflect the latest compliance data. The environment is set up with a dedicated ServiceNow user for API access, and the OAuth 2.0 credentials are stored securely in Genesys Cloud secrets. The timezone for the logs is Europe/London.
The Data Action is configured to trigger upon the completion of a QM evaluation. The payload includes the interactionId, evaluationId, score, and category. However, the integration is failing consistently with a 400 Bad Request error from the ServiceNow REST endpoint. Upon inspecting the ServiceNow system logs, the error message indicates: Error: JSON parse error: Unexpected character ('\' (code 92)): may not be used as an escape character. at [Source: REDACTED; line: 1, column: 45].
We have verified that the JSON structure is valid using external validators. The issue appears to stem from how Genesys Cloud handles special characters within the comment field of the evaluation, which contains escaped quotes and backslashes from agent notes. The standard Data Action mapping does not seem to properly encode these characters before transmission. We have attempted to use the encodeURI function within the Data Action script step, but the error persists. The API endpoint is https://<instance>.service-now.com/api/now/table/cmdb_ci_service.
Question:
What is the correct way to handle special character encoding in Data Action payloads when transmitting complex string fields from Genesys Cloud Quality Management to ServiceNow REST APIs? Is there a specific transformation step or JavaScript function within the Data Action context that ensures proper JSON serialization of nested strings containing escape sequences? We need a robust method to prevent 400 Bad Request errors due to malformed JSON without resorting to middleware proxies.