Data Actions: Handling Nested JSON Arrays from Legacy CRM APIs

I’m trying to retrieve customer order details from a legacy CRM using a Data Action. The CRM returns a heavily nested JSON structure where the ‘Orders’ array is buried inside several objects.

{
 "customer": {
 "account": {
 "history": {
 "orders": [
 { "id": "123", "status": "shipped" },
 { "id": "456", "status": "pending" }
 ]
 }
 }
 }
}

I can’t seem to get the ‘Translation Map’ to correctly extract the first order ID. I’ve tried $.customer.account.history.orders[0].id but the Data Action keeps failing with ‘Action execution failed: Request body is not valid JSON’ or simply returning an empty string. Does the Data Action translation engine have a limit on how deep it can traverse a JSON tree?

The depth shouldn’t be an issue, but the ‘Translation Map’ syntax is very picky. Make sure you aren’t wrapping the expression in quotes inside the translationMap block.

Also, check your ‘Output Contract’. If you’re expecting a String but the JSONPath returns an Array (even an array with one item), it will fail. Try using $.customer.account.history.orders[0].id and ensuring the Output Contract matches exactly. If you use $.customer..id (deep scan), it will return an array, which will definitely break a String-type output.

Another thing to check is the ‘Success Template’. If you’re using ${translationMapResults.orderId} but the value is missing in the JSON response, the resulting string might be malformed.

In our skills-based routing flows, we use a default value to avoid this: ${successTemplateUtils.firstNonnull(translationMapResults.orderId, "NOT_FOUND")}. This ensures that even if the JSONPath fails, the Data Action still returns a valid string back to Architect, which you can then handle with a ‘Decision’ block instead of hitting the ‘Failure’ path.