My response of the edpoint
“items”:[
{
“Role”:{
“id”:“A”,
“name”:“a”
},
“team”:{
“id”:2
“name”:“b”
}
}
…
]
}
in order to fetch this data im using rule:
import connector.common.JsonUtil;
import sailpoint.tools.Util;
log.error("Starting Web Service Aggregation Rule");
List<Map<String, Object>> identities = new ArrayList<>();
// Check if the response contains data
if (rawResponseObject != null && !rawResponseObject.isEmpty()) {
// Parse the raw JSON response into a Map
Map<String, Object> responseMap = JsonUtil.toMap(rawResponseObject);
// Check if "items" exists in the response
if (responseMap != null && responseMap.containsKey("items")) {
List<Map<String, Object>> items = (List<Map<String, Object>>) responseMap.get("items");
// Loop through each item in the "items" array
for (Map<String, Object> item : items) {
// Extract "Role" and "team" details
Map<String, Object> role = (Map<String, Object>) item.get("Role");
Map<String, Object> team = (Map<String, Object>) item.get("team");
if (role != null && team != null) {
// Create an identity record
Map<String, Object> identity = new HashMap<>();
identity.put("roleId", role.get("id"));
identity.put("roleName", role.get("name"));
identity.put("teamId", team.get("id"));
identity.put("teamName", team.get("name"));
// Add the identity record to the list
identities.add(identity);
}
}
} else {
log.error("'items' not found in the response");
}
} else {
log.error("Raw response object is null or empty");
}
// Log the aggregated identities for debugging
log.error("Aggregated Identities: " + identities);
// Return the aggregated data
return identities;