Data Action - Event Mapping - Incorrect Type?

Hi all, we’re trying to push call data into a third-party system using a Data Action in Architect, triggered from a Zoom Contact Center flow. The connector is configured with a POST request to https://api.example.com/v1/calls. It’s a pretty standard setup - OAuth is working, the connection test passes. However, the Data Action keeps failing with a 400 Bad Request. The error message from the third-party API is “Invalid type for field ‘call_duration’ - expected integer, got string.” I’m looking at the event mapping in the Data Action config, and the ‘call_duration’ field is coming through as a number from Genesys Cloud. The connector seems to maybe be changing it?

The mapping itself looks okay. I’m mapping call.callDuration (is that the right property name?) to call_duration on the target system. I’ve tried setting the target field type in the connector to “string” just to see if it will accept it, but then the error becomes “Invalid format for field ‘call_duration’ - expected ISO 8601 duration, got string”. It’s very strange. Here’s the relevant part of the Workato recipe log - it’s not super helpful.

2024-02-29 10:32:00 UTC - INFO - Executing Data Action: POST to https://api.example.com/v1/calls
2024-02-29 10:32:00 UTC - DEBUG - Request payload: {"call_id":"12345", "call_duration":"PT1M30S", "agent_id":"67890"}
2024-02-29 10:32:00 UTC - ERROR - Data Action failed with status code: 400
2024-02-29 10:32:00 UTC - ERROR - Error message: Invalid type for field ‘call_duration’ - expected integer, got string

I’m not sure what’s going on with the duration format. Maybe something with how Workato is passing it through?

We have seen this problem before. The Data Action sometimes sends everything as a string, even if you set the data type in the mapping. It’s frustrating - the documentation doesn’t really explain this clearly.

Try adding a toNumber() function in the Data Action mapping. For example, if your field is named call_duration, change the mapping expression to toNumber(call_duration). This will convert the string to a number before sending it to the API.

Here’s what the mapping should look like in Architect:

{
 "call_duration": toNumber(call_duration),
 "call_id": call_id,
 "caller_number": caller_number
}

I saw a similar workaround in the community last month - someone had the same issue with a different API, and the toNumber() function fixed it.

Also, check the Content-Type header in the Data Action configuration. It should be set to application/json. Sometimes it defaults to something else.

It’s a small thing, but we had an issue with a bot flow last week - the header was wrong, and nothing was posting correctly. The third-party system was just ignoring everything.

You’ll need to test again after this change, but this usually fixes the type mismatch.