Data Action with array of objects of variable size

Hello,

I have a API, which returns object in the following format:

{
	"conversationObject": {
		"conversationId": "058cf0dc-fc4a-4b7c-adc6-93f9ddde023c",
		"ClaimNumber" : 123456
		"prefferedAgent": [],
		"getHistoryCheck": [],
		"getHealthCheck": [],
		"getEnabledCheck": []
    }
}

wher preferredAgent is array of strings, where the size of the array can be different with each call of the API and getHistoryCheck, getHealthCheck and getEnabledCheck are arrays of object, which can also be of different size with every call.

So once the response can be like this:

{
	"conversationObject": {
		"conversationId": "058cf0dc-fc4a-4b7c-adc6-93f9ddde023c",
		"ClaimNumber" : 123456
		"prefferedAgent": ["john.doe@email.com"],
		"getHistoryCheck": [
			{ 
			  “ApplicationId”: "EACZ-APP-1042",       
			  “ReportGroupParentId”: 5, 
			  “Result”: true 
          }, 
         { 
              “ApplicationId”: "EACZ-APP-1066",       
              “ReportGroupParentId”: 5, 
              “Result”: true 
          }
		],
		"getHealthCheck": [],
		"getEnabledCheck": []
    }
}

and the other time like this:

{
	"conversationObject": {
		"conversationId": "058cf0dc-fc4a-4b7c-adc6-93f9ddde023c",
		"ClaimNumber" : 123456
		"prefferedAgent": ["john.doe@email.com","john.doe2@email.com"],
		"getHistoryCheck": [
			{ 
			  “ApplicationId”: "EACZ-APP-1042",       
			  “ReportGroupParentId”: 5, 
			  “Result”: true 
          }
		],
		"getHealthCheck": [],
		"getEnabledCheck": []
    }
}

What I would like to ask, is how to effectively handle this in the Data Action and also in the Architect, so I am able to access these values?

You can do this setup in the native Simple mode of the data action. Can be confusing when new to it.

Looks like:

Not added last 2 arrays as no example data, but you should get idea from first 2.

Json version

{
  "title": "response",
  "type": "object",
  "properties": {
    "conversationObject": {
      "type": "object",
      "properties": {
        "conversationId": {
          "type": "string"
        },
        "ClaimNumber": {
          "type": "integer"
        },
        "prefferedAgent": {
          "type": "array",
          "items": {
            "title": "Item 1",
            "type": "string"
          }
        },
        "getHistoryCheck": {
          "type": "array",
          "items": {
            "title": "Items",
            "type": "object",
            "properties": {
              "ApplicationId": {
                "type": "string"
              },
              "ReportGroupParentId": {
                "type": "integer"
              },
              "Result": {
                "type": "boolean"
              }
            },
            "additionalProperties": true
          }
        }
      },
      "additionalProperties": true
    }
  }
}

As for Architect, map to collections and iterate over them. You can check Count for number of entries

Tested with wiremock.cloud as mockable.io seems to have a cert issue when tried.

Sample response shown in Genesys


1 Like

Hello Simon,

thank you for your guidance! This is exactly what I was looking for. I am getting used to working with data actions, so this is definitely very helpful!