Scripting inside add access REST API

kp2345
New Contributor
New Contributor

Hi Team , 

This is the payload of my addaccess json . The target application only supports put operations with full payload 


    "data": {
        "id": "${account.accountID}",
        "userName": "${account.name}",
        "firstName": "${account.customproperty2}",
        "lastName": "${account.customproperty3}",
        "email": "${account.customproperty4}",
        "requirePasswordChange": "${account.customproperty5}",
        "passwordNeverExpire": "${account.customproperty7}",
        "suspended": "${account.customproperty8}",
        "failedLoginAttempts": "${account.customproperty9}",
        "dateFrozen": "${account.customproperty10}",,
        "roles": [
{
                "id": "${entitlementValue.entitlementID}"
},
            "${account.customproperty31}"
        ],
        "clearPassword": "${account.customproperty11}",,
        "adminPassword": "${account.customproperty12}",,
        "userType": "${account.customproperty13}",
        "externallyManaged": "${account.customproperty14}",
        "objectVersion": "${account.customproperty15}",
        "_href": "${account.customproperty16}",
    }   
 
 
value of     "${account.customproperty31}" = {"Roles":{"entIds":["admin,appsectester"],"keyField":"entitlementID"}} 


I want to modify my json such that the roles entry becomes like this 
 
"roles": [
{
                "id": "Tester"  #Current entitlementrequested
},
{
                "id": "admin"  #picked from cp31
},
{
                "id": "appsectester"   #picked from cp31
}
            
        ],
 
Please help me out here 
 
 
2 REPLIES 2

shivmano
Regular Contributor II
Regular Contributor II

@kp2345 , I would suggest using call1 in add access json to pull the existing access for the user and then using the response from call1 in call2 and adding the new entitlement so you can send the roles consolidated.

Here is a sample of how you can leverage call1 response value in call2. as a arraylist. 

roles\":${List responseList = response.Role1.message.roles.collect{it.id};responseList.add(entitlementValue.entitlement_value);List rolesList = new ArrayList();int count=0;int size = responseList.size();for(String str: responseList){count++;rolesList.add('{\"id\":\"'+str+'\"}');if(count == size){return rolesList;}}}

Darshanjain
Saviynt Employee
Saviynt Employee

Hi @kp2345 

Directly there is no json which can send as per your requirement, better way is to see if you have any Api which gives entitlement  details for users and  use two calls to get the data as suggested by @shivmano 

 

Thanks

Darshan