Hello,
For a web services source we need an after operation rule to make changes to the original response returned by the target API and concatenate differente values.
The problem lies in mapping the response in the source configuration. Even though the rule prints show that the result returned by the rule is correct in the logs, the JSON path does not work (tried with and without “data”). The only value I can retrieve is by replacing “data” with the name of the account attribute and returning the “processedResponseObject” variable, but in this case, the assigned value is a string that contains the original response received by the API before it was processed by the rule.
Example :
Original API response :
{
"id": "7C",
"grants": [
{
"subjectId": "7C",
"division": {
"id": "1",
"name": "D1",
"description": "D1"
},
"role": {
"id": "2",
"name": "R2",
"description": "R2"
}
},
{
"subjectId": "7C",
"division": {
"id": "11",
"name": "D11",
"description": "D11"
},
"role": {
"id": "22",
"name": "R22",
"description": "R22"
}
}
]
}
Response returned by the after rule (after the concatenation) :
{
"data": [
{
"subjectId": "8C",
"divisionRole": {
"id": "1 | 2"
},
"userId": "7C",
},
{
"subjectId": "8C",
"divisionRole": {
"id": "11 | 22"
},
"userId": "7C",
}
]
}
I am using the following after rule based on the oficial sailpoint tamplate :
import connector.common.JsonUtil;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.PrintStream;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import sailpoint.tools.GeneralException;
Map updatedMapInfo = new HashMap();
List list = new ArrayList();
ArrayList<String> Roles = new ArrayList<String>();
Map response = (Map) JsonUtil.toMap(rawResponseObject);
List Finallist = new ArrayList();
log.info("=> RULES response at start" + response);
if (response.get("grants") != null) {
String userId = (String) response.get("id");
log.info("=> this is userId" + userId);
list = (ArrayList) response.get("grants");
log.info("=> this is grants list" + list);
for(int d = 0; d < list.size(); d++ ){
Map responseMap = (Map) list.get(d);
log.info("=> Processing grant " + d);
log.info("=> this is responseMap" + responseMap);
String subjectId = (String) responseMap.get("subjectId");
Map division = (Map) responseMap.get("division");
Map role = (Map) responseMap.get("role");
if (division != null && role != null) {
// Create the divisionRole object
Map divisionRole = new HashMap();
String divisionId = division.get("id");
String roleId = role.get("id");
String concatenatedDivisionRoleId = divisionId + " | " + roleId;
divisionRole.put("id", concatenatedDivisionRoleId);
// divisionRole.put("id", division.get("id") + " | " + role.get("id"));
// divisionRole.put("name", division.get("name") + " | " + role.get("name"));
// divisionRole.put("description", division.get("description") + " | " + role.get("description"));
log.info("=> Created divisionRole: " + divisionRole);
// Create the transformed object
Map transformedGrant = new HashMap();
transformedGrant.put("subjectId", subjectId);
transformedGrant.put("divisionRole", divisionRole);
transformedGrant.put("userId", userId);
Finallist.add(transformedGrant);
}
}
}
log.info("=> RULES Finallist at end" + Finallist);
log.info("=> RULES processedResponseObject Before is " + processedResponseObject);
updatedMapInfo.put("data", Finallist);
log.info("=> RULES updatedMapInfo is " + updatedMapInfo);
return updatedMapInfo;
The rule is used in the account aggregation and the get object calls.
Thanks in advance for your help !