Nested JSON objects only show data when "flatten output" is unchecked

I'm building a Data Action to call
GET /api/v2/telephony/providers/edges/trunkbasesettings

This, by default, returns the results as a top-level object, and in that, an array called entities. I'm trying to configure my data action to only return the first entity in the array, as my queries will only ever have a single entity in the first place.

I have this working with the attached action, but when I go to use the web interface to test it, it only returns a value for trunk_maxCalls_trunkbase.value.instance if "flatten output" is unchecked.

All the action is doing is

  1. Call the API to get the response, based on a single string input for the URL param
  2. Use translation map to bind the nested array into a variable
  3. In the success template, take the first entry from the array, to simplify the output format of the data action to a single object

Get-Trunk-Settings-20240618125448.custom.json (1.7 KB)

With Flatten Output checked

With Flatten Output unchecked

Hi,

Since you are getting the config of only one trunk, you can set the following:

Output Contract:

{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"value": {
"type": "number"
}
},
"additionalProperties": true
}

Response:

{
"translationMap": {
"id": "$.entities[0].id",
"name": "$.entities[0].name",
"value": "@.entities[0].properties.trunk_maxCalls_trunkbase.value.instance"
},
"translationMapDefaults": {},
"successTemplate": "{\n "id" : ${id} \n, \n "name": ${name} \n, \n "value" : ${value} \n}"
}

This will work irrespective of flattening the output.

Thanks and Regards,
Sriram L

That strategy worked, but I formatted the successTempalte to not have the line breaks. This is my response configuration now.

{
  "translationMap": {
    "id": "$.entities[0].id",
    "name": "$.entities[0].name",
    "maxCalls": "$.entities[0].properties.trunk_maxCalls_trunkbase.value.instance"
  },
  "translationMapDefaults": {},
  "successTemplate": "{\"id\" : ${id}, \"name\": ${name}, \"maxCalls\" : ${maxCalls}}"
}

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.