How to aggregate WS Rest API data if response is an annonymous array?

Hi all! I have a Web Service that returns a json like this:

  [
    {
      "id": "xxx",
      "fieldN": "....."
    },
    {
      "id": "yyy".
      "fieldN": "...."
    }
]

I am having trouble in getting aggregation work. I tried several root paths, por example
-blank-
$
$.
$.[*]

But all returns 0 accounts. I have in the same tenant another WS, that has the structure

{
  "data":
    [
      {
        "id": "xxx",
        "fieldN": "....."
      },
      {
        "id": "yyy".
        "fieldN": "...."
      }
    ]
}

and Root Path $.data works fine. I think problem comes whith other WS because array is annonymous. Have anybody deal with some ws like this?

Here’s an example where I’m only pulling in a single attribute “groupId”. In this case it’s the second step of an account aggregation process in which we are only pulling in a list of group Id’s associated with each user:

Map newMap = new HashMap();
List newList1 = new ArrayList();
for(Map m : processedResponseObject) {
	if(m.get("groupId") != null) { newList1.add(m.get("groupId")); }
}
newMap.put("groupId", newList1);
processedResponseObject = new ArrayList();
processedResponseObject.add(newMap);
Map returnMap = new HashMap();
returnMap.put("data", processedResponseObject);
return returnMap;
1 Like

Hi, after some headaches of trying/error we find solution.

On root path, we left only $[*]

image

Then, on Response Mapping configuration, we left attribute path columns with field names only. We are getting accounts now.

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