Data Action - Weird Payload Encoding with PureCloudPlatformClientV2

Been chasing a really odd issue with data actions in Architect - it’s not a typical serialization problem, which is what threw me at first. We’ve got a flow that’s supposed to be POSTing call data to a webhook (/api/v2/integrations/webhooks/{tokenId}/events) after a call ends, but the webhook is receiving a garbled payload. PureCloudPlatformClientV2 seems to be adding extra backslashes to the JSON string - escaping characters that shouldn’t be escaped. It’s like it’s double-escaping things.

The webhook logs show requests with payloads like this: {\"callId\":\"12345\",\"callerId\":\"+15551234567\"} - see the extra backslashes? It’s happening consistently, and it’s breaking the JSON parsing on the receiving end. I’m constructing the payload object with plain JavaScript, nothing fancy, and then passing it to PureCloudPlatformClientV2.ApiClient.callApi - should be straightforward. Feels like the SDK is doing something unexpected during serialization.

We saw similar behavior - INC-4471 - and it was related to how the data action’s “Request Body” field handles JSON. The documentation states that “The request body is sent as a string”, but it appears the Client App SDK is attempting to serialize it again, causing the double-escaping.

Try setting the “Content-Type” header to “application/json” in the data action configuration - it’s a small thing, but it helps the webhook interpret the payload correctly. Also, make sure your JSON is valid to start with → invalid JSON → webhook fails.

Instead of building the JSON string directly in the flow, you could also consider using a “Set Variable” action to construct the JSON object, and then reference that variable in the data action’s Request Body. This might prevent the extra serialization step.

We found in our testing that if the Request Body contains characters that need to be escaped, such as quotes, they should be escaped once before being added to the data action. The SDK is then handling the second level of encoding. The documentation doesn’t explicitly state this, but it seems to be how it works.

The documentation on data actions is here: https://developer.genesys.cloud/reference/architect/data-actions - it’s not super clear on the serialization, but it’s a starting point.

1 Like