Data Action and Array of Objects

Hi all,

I am unable to parse the response of a data action. The response that I am getting from the API endpoint is:

{
  "result": [
    {
      "number": "CS1743419",
      "short_description": "Test Case from Genesys via API 2",
      "sys_id": "58a77c433be79610b70f100864e45a28",
      "state": "New",
      "work_notes": "2025-02-10 07:14:33 - Animesh Mulasi (Work notes)\nNotes Updated\n\n",
      "assigned_to": "Animesh Mulasi"
    },
    {
      "number": "CS1743418",
      "short_description": "Test Case from Genesys via API 1",
      "sys_id": "5e97bc4733271a10fa7c3542cd5c7b4c",
      "state": "New",
      "work_notes": "2025-02-11 02:25:12 - Animesh Mulasi (Work notes)\nWork notes update 1\n\n",
      "assigned_to": "Animesh Mulasi"
    },
    {
      "number": "CS1743421",
      "short_description": "Test Case from Genesys via API 4",
      "sys_id": "71a7bc433be79610b70f100864e45a04",
      "state": "New",
      "work_notes": "2025-02-11 02:26:21 - Animesh Mulasi (Work notes)\nWork notes update 1\n\n",
      "assigned_to": "Animesh Mulasi"
    }
  ]
}

I want to parse this data which is an array of objects. My output contracts are:

{
  "title": "Output",
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "result": {
      "type": "array",
      "items": {
        "title": "Case",
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "number": {
            "type": "string"
          },
          "work_notes": {
            "type": "string"
          },
          "short_description": {
            "type": "string"
          },
          "sys_id": {
            "type": "string"
          },
          "state": {
            "type": "string"
          }
        }
      }
    }
  }
}

My response configuration is:

{
  "translationMap": {
    "number": "$.result[*].number",
    "short_description": "$.result[*].short_description",
    "sys_id": "$.result[*].sys_id",
    "state": "$.result[*].state",
    "work_notes": "$.result[*].work_notes"
  },
  "translationMapDefaults": {},
  "successTemplate": "{\n \"Case.number\": ${number},\n \"Case.work_notes\": ${work_notes},\n \"Case.short_description\": ${short_description},\n \"Case.sys_id\": ${sys_id},\n \"Case.state\": ${state}}"
}

This action is running successfully but I am not able to get the data in output contracts. Please see the attached screenshot.
I configured the output contract based on a forum post which I came across earlier:

Could anyone please help?

Hello,

What you have defined in your Output Contract already matches the format of your response.

So you can just use the following in your Response Configuration:

{
  "translationMap": {},
  "translationMapDefaults": {},
  "successTemplate": "${rawResult}"
}

During your test, don't flatten output.

Regards,

It appears that you have configured your output contract to be the same as the response from the endpoint, which is great! I was able to get a correct response by going back to the default output configuration:

{
  "translationMap": {
  },
  "translationMapDefaults": {},
  "successTemplate": "${rawResult}"
}

However the new UI does not appear to display the results correctly if the output is flattened. The JSON looks correct though, so I will enter a ticket to see what is going on with the UI.

--Jason

Hello @Jerome.Saint-Marc ,

Thank you for the response. I run the action without flattening the output and got data in my output contract but it's not as per my requirement. I have created the output contract to create arrays of objects from the response. I think I have to log a ticket for it. It seems something is wrong with the new UI.

Regards,
Animesh

Hello @Jason_Mathison

Thank you for your response. I will log a ticket for it.

Regards,
Animesh

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