Retrieving and parsing existing Entitlement values in REST connector

piyushm
Regular Contributor II
Regular Contributor II

Hello,

We have an application where there is no Add/Remove API to update the entitlements for an user. Instead we need to call update API and send the existing entitlements and new entitlement as an array to add new entitlements. Now I understand that we need 2 calls, one to retrieve the Roles and the 2nd one to pass the array.

The first API response is as below to get one specific user details. The response does not have any name for the result.

{
    "isActive"true,
    "email""john6.doe@abc.com",
    "firstName""Johnn",
    "lastName""Dave",
    "phone""+xxxxxxx",
    "roles": [
        1, 2
    ]
}
 
I found below snippet from the connector guide but i want to know how to iterate through the array of roles in the first response above. Also what will be map.name in my case?
 
"httpParams": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><user><roles>${String rolesStr = '';int size = response.Role1.message.roles?.size();int i = 0;for (Map map : response.Role1.message.roles){if(!map.name.equals(entitlementValue.entitlement_value)){rolesStr=rolesStr+'<role><name>'+map.name+'</name></role>';i++;if(i == size){return rolesStr;}}else{i++;if(i == size){return rolesStr;}}}}</roles></user>"
 
1 REPLY 1

SB
Saviynt Employee
Saviynt Employee

You can refer the below article for this requirement.

https://forums.saviynt.com/t5/community-knowledge-base/rest-conn-retain-existing-entitlements-and-on...


Regards,
Sahil