Web Service After Operation Rule

Hi Team,

I am working on Web Service Connector and we have 3 end points as below:
a. Account Aggregation: v1/users (No group details available)
Response:

<feed xmlns="http://www.w3.org/2005/Atom">
    <id>tag:sap.com,2010:bip-rs/infostore</id>
    <title type="text">user</title>
    <updated>2025-02-07T07:17:06.948Z</updated>
    <link href="https://cafil0110win.intl.intlroot.fid-intl.com:8443/biprws/v1/users/?page=1&amp;pagesize=50" rel="self"></link>
    <link href="https://cafil0110win.intl.intlroot.fid-intl.com:8443/biprws/v1/users/?page=1&amp;pagesize=50" rel="first"></link>
    <link href="https://cafil0110win.intl.intlroot.fid-intl.com:8443/biprws/v1/users/?page=2&amp;pagesize=50" rel="next"></link>
    <link href="https://cafil0110win.intl.intlroot.fid-intl.com:8443/biprws/v1/users/?page=22&amp;pagesize=50" rel="last"></link>
    <entry>
        <title type="text">a786166</title>
        <id>tag:sap.com,2010:bip-rs/Ad5I98blISZJj0Mf5g4nGgo</id>
        <updated>2025-02-03T21:00:47.235Z</updated>
        <link href="https://cafil0110win.intl.intlroot.fid-intl.com:8443/biprws/v1/users//1720045" rel="alternate"></link>
        <content type="application/xml">
            <attrs xmlns="http://www.sap.com/rws/bip">
                <attr name="cuid" type="string">Ad5I98blISZJj0Mf5g4nGgo</attr>
                <attr name="name" type="string">a786166</attr>
                <attr name="description" type="string"></attr>
                <attr name="id" type="string">1720045</attr>
                <attr name="fullname" type="string">Banerjee, Upasana</attr>
                <attr name="type" type="string">User</attr>
                <attr name="ownerid" type="string">1720045</attr>
                <attr name="updated" type="string">Feb 3, 2025 4:00 PM</attr>
                <attr name="parentid" type="string">19</attr>
            </attrs>
        </content>
    </entry>
</feed>

b. Group Aggregation: v1/usergroups (No groupmember details available)
Response:

<feed xmlns="http://www.w3.org/2005/Atom">
    <id>tag:sap.com,2010:bip-rs/infostore</id>
    <title type="text">usergroup</title>
    <updated>2025-02-03T07:54:26.813Z</updated>
    <link href="http://cafil0110win.intl.intlroot.fid-intl.com:8080/biprws/v1/usergroups?page=1&amp;pagesize=50" rel="self"></link>
    <link href="http://cafil0110win.intl.intlroot.fid-intl.com:8080/biprws/v1/usergroups?page=1&amp;pagesize=50" rel="first"></link>
    <link href="http://cafil0110win.intl.intlroot.fid-intl.com:8080/biprws/v1/usergroups?page=2&amp;pagesize=50" rel="next"></link>
    <link href="http://cafil0110win.intl.intlroot.fid-intl.com:8080/biprws/v1/usergroups?page=2&amp;pagesize=50" rel="last"></link>
    <entry>
        <title type="text">User_Group_Test</title>
        <id>tag:sap.com,2010:bip-rs/AawV4xkwfC5LilFPy0kodMQ</id>
        <updated>2025-01-30T08:01:42.869Z</updated>
        <content type="application/xml">
            <attrs xmlns="http://www.sap.com/rws/bip">
                <attr name="cuid" type="string">AawV4xkwfC5LilFPy0kodMQ</attr>
                <attr name="keywords" type="string"></attr>
                <attr name="name" type="string">User_Group_Test</attr>
                <attr name="description" type="string">This is only test user</attr>
                <attr name="id" type="string">1547098</attr>
                <attr name="type" type="string">UserGroup</attr>
                <attr name="updated" type="string">Jan 30, 2025 3:01 AM</attr>
                <attr name="parentid" type="string">20</attr>
            </attrs>
        </content>
    </entry>
</feed>

c. Group Member Aggregation(2nd Account Aggregation): v1/usergroups/groupid/members (Only member details are available)
Response:

<feed xmlns="http://www.w3.org/2005/Atom">
    <title type="text">usergroup</title>
    <updated>2025-02-03T15:28:52.738Z</updated>
    <entry>
        <title type="text">a785490</title>
        <updated>2025-02-03T15:28:52.972Z</updated>
        <link href="http://cafil0110win.intl.intlroot.fid-intl.com:8080/biprws/v1/usergroups/1419247/users" rel="alternate"></link>
        <content type="application/xml">
            <attrs xmlns="http://www.sap.com/rws/bip">
                <attr name="cuid" type="string">AdXfNEh6wCNIgol9lnxtYJ4</attr>
                <attr name="keywords" type="string"></attr>
                <attr name="created" type="string"></attr>
                <attr name="name" type="string">a785490</attr>
                <attr name="description" type="string"></attr>
                <attr name="**id**" type="string">**1713810**</attr>
                <attr name="fullname" type="string">Leung, King Yiu</attr>
                <attr name="updated" type="string" null="true"></attr>
                <attr name="email" type="string">KingYiu.Leung@fidelity.ca</attr>
            </attrs>
        </content>
    </entry>
    <entry>
        <title type="text">A783202</title>
        <updated>2025-02-03T15:28:53.019Z</updated>
        <link href="http://cafil0110win.intl.intlroot.fid-intl.com:8080/biprws/v1/usergroups/1419247/users" rel="alternate"></link>
        <content type="application/xml">
            <attrs xmlns="http://www.sap.com/rws/bip">
                <attr name="cuid" type="string">AWygKgPe1JhJr.Gd59AbZK8</attr>
                <attr name="keywords" type="string"></attr>
                <attr name="created" type="string"></attr>
                <attr name="name" type="string">A783202</attr>
                <attr name="description" type="string"></attr>
                <attr name="id" type="string">1713811</attr>
                <attr name="fullname" type="string">Bethel, Amber</attr>
                <attr name="updated" type="string" null="true"></attr>
                <attr name="email" type="string">Amber.Bethel@fidelity.ca</attr>
            </attrs>
        </content>
    </entry>
</feed>

Note: We get XML response.
Currently I have configured Group Aggregation as parent endpoint(to fetch the group details) and Account Aggregation as child (to map those groups to its members)

Expectation: We are trying to map the accounts with its group details as there is no straight forward way, so i am trying to build a Web Service After Operation Rule to extract each group, map the member details so group-to-account relation can be made.

However I am getting parse error for using “List<Map<String, Object>>”, I have referred the javadoc and connector doc but did not get any details. Can you please help me with this issue?

		import java.util.Arrays;
		import java.util.Map;
		import java.util.ArrayList;
		import java.util.HashMap;
		import java.util.*;
		import connector.common.JsonUtil;
		import connector.common.Util;
		import sailpoint.connector.webservices.EndPoint;
		import sailpoint.connector.webservices.WebServicesClient;
		import sailpoint.tools.xml.XMLResponseUtil;
 
        
		log.error("Starting the FICBO WebServiceAfterOperationRule");
		try{
		WebServicesClient client = new WebServicesClient();
                Map args1 = new HashMap();
		Map args2 = new HashMap();
		Map userGroupMapping = new HashMap();
		String token = "xxxxxxxxx";
		Map header = new HashMap();
		header.put("X-SAP-LogonToken", token);
        header.put("Content-Type","application/xml");
		header.put("Accept","application/xml");
		
		List<String> allowedStatuses = new ArrayList();
        allowedStatuses.add("2**");
		String groupsEndpoint = "http://cafil0110win.intl.intlroot.fid-intl.com:8080/biprws/v1/usergroups";
		log.error("Printing the groupsEndpoint" + groupsEndpoint);
		args1.put(WebServicesClient.ARG_URL, groupsEndpoint);
		client.configure(args1);
		String groupresponse = client.executeGet(groupsEndpoint, header, allowedStatuses);
		log.error("Printing the response" + groupresponse);

		// Parse the XML response and convert it to a list of maps
		List<Map<String, Object>> groups = parseXmlResponseToListOfMaps(groupresponse);

		for (Map<String, Object> group : groups) {
			String groupId = (String) group.get("id");
			log.error("Printing the groupId values" + groupId);
			String groupName = (String) group.get("name");
			log.error("Printing the groupname values" + groupName);
 
			//Fetch users assigned to this group
            String groupMembersEndpoint = "http://cafil0110win.intl.intlroot.fid-intl.com:8080/biprws/v1/usergroups/" + groupId + "/users";
			log.error("Printing the groupMembersEndpoint"+groupMembersEndpoint);
            args2.put(WebServicesClient.ARG_URL, groupMembersEndpoint);
			client.configure(args2);
			String groupMemberResponse = client.executeGet(groupMembersEndpoint, header, allowedStatuses);
			log.error("Printing the response" + groupMemberResponse);
 
			List<Map<String, Object>> members = parseXmlResponseToListOfMaps(groupMemberResponse);
            for (Map<String, Object> member : members) {
				log.error("Printing the members values inside for loop" +member);
                String userId = (String) member.get("id");
				log.error("Printing the userId values inside for loop"+userId);
 
                // Add group to the respective user in the mapping
                List userGroups = userGroupMapping.get(userId);
				if (userGroups == null) {
					userGroups = new ArrayList();
					userGroupMapping.put(userId, userGroups);
				}
				userGroups.add(groupName);
				log.error("Printing the userGroups inside the loop"+userGroups);
				log.error("Printing the userGroupMapping inside the loop"+userGroupMapping);
            }
        }
 
		log.info("User to Group Mapping outside the loop " + userGroupMapping);
        return userGroupMapping;
		}
		catch (Exception e) {
        log.error(e.getMessage(), e);
		}	

SailPoint doesn’t allow the use of generics in the beanshell code. I see you have provided generics in your beanshell logic. Try to modify all the generic statements and try again.

Based on your code:

Incorrect syntax : 
List<Map<String, Object>> groups = parseXmlResponseToListOfMaps(groupresponse);

Correct Syntax :
List groups = parseXmlResponseToListOfMaps(groupresponse);

Similarly correct all the generics in your code and retry.

Thanks,
Arshad.

1 Like

Hi @Arshad ,

I have also tried “List groups = parseXmlResponseToListOfMaps(groupresponse);” where i get typed exception

To hold the value of groupresponse, declare a string and assign it to the string variable. Then convert it to Map/List whichever is applicable for your use case.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.