WebServiceBeforeOperationRule -create account with Ent addition

Hi,

I have attached the webservicebeforeoperationrule on create operation. received below error.

Error:

Rule Error: java.lang.RuntimeException: Source JSON is not a Map. class java.lang.String cannot be cast to class java.util.Map (java.lang.String and java.util.Map are in module java.base of loader ‘bootstrap’)"

<ProvisioningPlan nativeIdentity="50001014">

<AccountRequest application="xxx-Realtime \[source\]" op="Create">

<AttributeRequest name="ctmsPrivilegeId" op="Add" value="12"/>

<AttributeRequest name="enterprisePrivilegeId" op="Add">

  <Value>

    <List>

      <String>103</String>

      <String>104</String>

    </List>

  </Value>

</AttributeRequest>

<AttributeRequest name="email" op="Add" value="NewEE_14@t.com"/>

</AccountRequest>

<Attributes>

<Map>

  <entry key="accessRequestType" value="GRANT_ACCESS"/>

  <entry key="identityRequestId" value="910c5a2e02d542bbb6596ff8465e63ce"/>

  <entry key="requester" value="00390644"/>

  <entry key="source" value="LCM"/>

</Map>

</Attributes>

</ProvisioningPlan>

create account JSONbody :

{

“active”: true,

“ctmsSystemUser”: true,

“email”: “$plan.email$”,

“firstName”: “$plan.firstName$”,

“lastName”: “$plan.lastName$”,

“userName”: “T.NewLn15”,

“ctmsPrivileges”: [

“$plan.ctmsPrivilegeId$”

],

“enterprisePrivileges”: [

103,

104

]

}

Rule:

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import connector.common.JsonUtil;
import connector.common.Util;
import sailpoint.connector.webservices.EndPoint;
import sailpoint.connector.webservices.WebServicesClient;
import sailpoint.object.Application;
import sailpoint.object.ProvisioningPlan;
import sailpoint.object.ProvisioningPlan.AccountRequest;

Map body = requestEndPoint.getBody();
String jsonBody = (String) body.get(“jsonBody”);

log.error(“Entered Realtime9 BeforeOperation Single AccountRule”);
try {
Map jsonMap = JsonUtil.toMap(jsonBody);
if (jsonMap != null) {
String ctmsPrivilegeId = “”;
if (provisioningPlan != null) {
log.info(“realtime9 beforeRule - Modify Body: plan is not null”);
for (AccountRequest accReq : Util.iterate(provisioningPlan.getAccountRequests())) {
log.info(“realtime9 beforeRule - Modify Body: iterating over account requests”);
for (ProvisioningPlan.AttributeRequest attReq : Util.iterate(accReq.getAttributeRequests())) {
log.info(“realtime9 beforeRule - Modify Body: iterating over attribute requests”);
String attrName = attReq.getName();
String value = null;
if (attrName != null && “ctmsPrivilegeId”.equalsIgnoreCase(attrName)) {
ctmsPrivilegeId = (String) attReq.getValue();
log.info("realtime9 beforeRule - Modify Body: setting ctmsPrivilegeId = " + ctmsPrivilegeId);
}
}
}
} else {
log.info(“realtime9 befRule - Modify Body: plan is null”);
}

if (!"".equals(ctmsPrivilegeId)) {
    jsonMap.put("ctmsPrivilegeId", ctmsPrivilegeId);
}

    String finalBody = JsonUtil.render(jsonMap);
    body.put("jsonBody", finalBody);
    requestEndPoint.setBody(body);
}

} catch (Exception ex) {
log.error(“Realtime9 beforeRule Error: " + ex);
}
return requestEndPoint;

Based on all my previous work, finalBody here should be String version of a JSONObject, and not Map. But based on

and

jsonMap is a Map, not JSONObject, which could be causing the issue

1 Like