Fun one today. We’ve got a Studio flow - it’s calling a custom endpoint to enrich contact data, and it’s intermittently failing with a 400 Bad Request. It’s not consistent, which makes it…interesting.
The flow’s logic is fairly straightforward. We’re kicking off a sub-flow when a contact enters a specific queue. Inside that sub-flow, there’s a GetRESTProxy activity. The target endpoint is /api/v3/contacts/enrich, and we’re POSTing a JSON payload. The payload structure dynamically changes based on a few variables set earlier in the flow - specifically, contact.customField1 and interaction.channel.
Pseudo-code for the payload construction looks like this:
{
"contactId": contact.id,
"channelType": interaction.channel,
"additionalData":
IF contact.customField1 == "A" THEN
{ "fieldA": "valueA" }
ELSE IF contact.customField1 == "B" THEN
{ "fieldB": "valueB" }
ELSE
{} // Empty object if neither A nor B
}
The odd thing is, the 400s only happen when contact.customField1 is “B”. When it’s “A” or blank, the call succeeds every time. The server logs show the request body is slightly different when it fails - specifically, there’s an extra comma at the end of the fieldB object when the value is populated. It’s like Studio is appending a rogue comma.
We’re on CXone Studio version 23.1. The REST API integration is configured with a basic authentication profile. The GetRESTProxy activity’s “Content Type” is set to “application/json”. We’ve tried escaping the commas using \, but that doesn’t seem to resolve the issue.
I suspect there’s something subtle going on with how Studio handles dynamic JSON construction, or perhaps it’s an interaction between the variable assignment and the REST proxy. Don’t hesitate to ask for more details. It’s a bit of a rabbit hole.