I am creating a method that will fetch the user details from a WebServices Connector.
I can’t make it work. It keeps throwing exception.
Could anyone use there expertise here?
String getUserDetails(String baseUrl,String username,String password,String id, WebServicesClient client) throws Exception {
String basicAuth = Base64.getEncoder().encodeToString((username + ":" + password).getBytes());
String url = baseUrl + "/contacts/XXXXXX/" + id + "?idType=id";
Map headers = new HashMap();
headers.put("Authorization", String.format("Basic %s",basicAuth));
headers.put("accept", "application/json");
List allowedStatuses = new ArrayList();
allowedStatuses.add("200");
try{
String response = client.executeGet(url,headers,allowedStatuses);
if(response == null || response.trim().isEmpty()){
throw new Exception("API returned empty or null response");
}
log.info(logPrefix + "- User detail response: " + response);
return response;
}
catch (Exception e){
throw new Exception("Failed to get user details: " + e.getMessage());
}
}
String baseUrl = (String) application.getAttributeValue("genericWebServiceBaseUrl");
String username = (String) application.getStringAttributeValue("username");
String password = (String) application.getStringAttributeValue("password");
WebServicesClient client = new WebServicesClient();
String id = null;
if (provisioningPlan != null){
List accountRequests = provisioningPlan.getAccountRequests();
if (accountRequests != null){
for (AccountRequest accReq : accountRequests){
id = accReq.getNativeIdentity();
log.error(logPrefix + "myid" + id);
}
}
}
String userDetails = getUserDetails(baseUrl,username,password,id,client);
Can you share some more information like what kind of exceptions you are encountering? And the import statements that you have used as well would also help others identify what might be going wrong.
A more detailed error information could be a good starting point and additionally,
can you test it like this: headers.put(“Authorization”, "Basic " + basicAuth);
in your headers not sure if it would make any difference but you are already adding a space after Basic and then adding %s which further introduces a space.
[“Exception occurred while performing \u0027Modify\u0027 operation on identity \u0027291529536652808\u0027: Error: Error executing before operation rule for endpoint \u0027Dummy Operation\u0027: The application script threw an exception: java.lang.Exception: Failed to get user details: null BSF info: FinalWebserviceRule at line: 0 column: columnNo”]
So this is again my assumptions to first know whats going on:
Can you confirm the following your rule is being invoked for what kind of operation? (Ex: Create, Add/Remove, Disabled, etc).
Can you get the user details via postman to cancel the doubt around the userDetail actually existing. And are you using the right nativeIdentity when making this call.
Post this we can proceed with the further debugging and in the meantime can you also use SailPoint internal classes for JSON Path manipulation/processing? Java docs | SailPoint Developer Community
Try to do just syncing identity attribute value into the targeted system by building dynamic payload. I would to make a GET call to Target system, fetch the user detail like email and phone. And check if these value exist in Target system or not.
Yes, I can get the details via postman.
I am not sure about this “And are you using the right nativeIdentity when making this call” but id is the nativeidentity.