Hi ,
im receiving an error saying “soruce json is not a map”
what might be the issue?
import java.util.Map;
import connector.common.JsonUtil;
import connector.common.Util;
import sailpoint.object.ProvisioningPlan;
import sailpoint.object.ProvisioningPlan.AccountRequest;
Map body = requestEndPoint.getBody();
String jsonBody = (String) body.get("jsonBody");
log.info("Rule - Modify Body: running");
try {
// Parse JSON body into a map
Map jsonMap = JsonUtil.toMap(jsonBody);
String rolesProducts = "";
// Extract roles-products from the provisioning plan
if (provisioningPlan != null) {
log.info("Rule - Modify Body: processing provisioning plan");
for (AccountRequest accReq : Util.iterate(provisioningPlan.getAccountRequests())) {
for (ProvisioningPlan.AttributeRequest attReq : Util.iterate(accReq.getAttributeRequests())) {
String attrName = attReq.getName();
if ("roles-products".equalsIgnoreCase(attrName)) {
rolesProducts = (String) attReq.getValue();
log.info("Rule - Modify Body: found roles-products = " + rolesProducts);
break;
}
}
}
}
if (!rolesProducts.isEmpty()) {
// Split roles-products into roleName and productName
String roleName = "";
String productName = "";
String[] parts = rolesProducts.split(":");
if (parts.length == 2) {
roleName = parts[0].trim();
productName = parts[1].trim();
}
// Add roleName and productName to the JSON map
jsonMap.put("roleName", roleName);
jsonMap.put("productName", productName);
log.info("Rule - Modify Body: roleName = " + roleName + ", productName = " + productName);
}
// Serialize updated JSON map and update the request body
String finalBody = JsonUtil.render(jsonMap);
body.put("jsonBody", finalBody);
requestEndPoint.setBody(body);
} catch (Exception ex) {
log.error("Rule - Modify Body: " + ex);
}