Hi All,
I am trying to write Before Operation rule, getting this error
```Error in method invocation: Method executeGet(java.lang.String, java.util.HashMap) not found in class\u0027sailpoint.connector.webservices.WebServicesClient\u0027 : at Line: 50 : in file: inline evaluation of: ``import java.util.; import sailpoint.tools.; import connector.common.JsonUtil; . . . \u0027\u0027 : restClient .executeGet ( getUrl , headers ) \n BSF info: SplunkRoleRemove at line: 0 column: columnNo"]
Checked everywhere on executeGet not sure why getting this error, anyone have any idea if I am missing anything?
```<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Rule name="SplunkRoleRemoval" type="WebServiceBeforeOperationRule">
<Description>Removes a role and updates user roles in Splunk</Description>
<Source><![CDATA[
import java.util.*;
import sailpoint.tools.*;
import connector.common.JsonUtil;
import sailpoint.object.*;
import connector.common.Util;
import org.json.JSONObject;
import org.json.JSONArray;
log.debug("WSBO Rule Started");
try {
// STEP 1: Retrieve the userId and role to remove from the provisioning plan
String userId = null;
String roleToRemove = null;
if (provisioningPlan != null) {
for (AccountRequest accReq : Util.iterate(provisioningPlan.getAccountRequests())) {
userId = accReq.getNativeIdentity();
log.debug("UserId to update: " + userId);
for (ProvisioningPlan.AttributeRequest attReq : Util.iterate(accReq.getAttributeRequests())) {
String attrName = attReq.getName();
if ("roles".equalsIgnoreCase(attrName)) {
roleToRemove = (String) attReq.getValue();
}
}
}
}
if (userId == null || roleToRemove == null) {
throw new IllegalArgumentException("UserId or role to remove not found in the provisioning plan.");
}
log.debug("Role to remove: " + roleToRemove);
// STEP 2: Get the user's current roles from Splunk via API (GET)
String bearerToken = "xxxx"; // Use your actual token
String baseUrl = "xxxxxx";
String getUrl = baseUrl + userId; // Full URL to call the API with userId
// Headers setup
Map headers = new HashMap();
headers.put("Authorization", "Bearer " + bearerToken);
// RestClient setup
Map args = new HashMap();
args.put(WebServicesClient.ARG_URL, baseUrl); // Set the base URL
restClient.configure(args); // Configure the restClient with base URL
// STEP 3: Execute GET request to retrieve current roles using `executeGet` method
String response = restClient.executeGet(getUrl, headers); // This is the key change
// Parse the response JSON to get the roles
JSONObject jsonResponse = new JSONObject(response);
JSONArray currentRolesArray = jsonResponse.getJSONArray("roles");
List updatedRoles = new ArrayList();
for (int i = 0; i < currentRolesArray.length(); i++) {
String role = currentRolesArray.getString(i);
if (!role.equalsIgnoreCase(roleToRemove)) {
updatedRoles.add(role);
}
}
// STEP 4: Create PATCH body to update the roles in Splunk
Map updatePayload = new HashMap();
updatePayload.put("roles", updatedRoles);
// Convert the payload to JSON
String jsonPayload = JsonUtil.render(updatePayload);
log.debug("Final PATCH Payload for Splunk API: " + jsonPayload);
// STEP 5: Send the PATCH request to Splunk API to update roles
String patchUrl = baseUrl + userId;
String patchResponse = restClient.executePatch(patchUrl, jsonPayload, headers);
log.debug("Splunk API PATCH Response: " + patchResponse);
// STEP 6: Set the updated payload to the request body
Map body = requestEndPoint.getBody(); // Access the existing requestEndPoint
body.put("jsonBody", jsonPayload);
requestEndPoint.setBody(body); // Set the updated body
} catch (Exception e) {
log.debug("Error in WebServiceBeforeOperationRule: " + e.getMessage());
throw e; // Re-throw the exception to indicate failure in the rule
}
return requestEndPoint;
]]></Source>
</Rule>