Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

Iterate a response in REST - removeAccess JSON

vinitamulchanda
New Contributor II
New Contributor II

While configuring usecase for removeAccess JSON in REST connector, I want to make two calls.

1. GET call to get user payload from Target.

2. PUT call to send the updated payload to target, in the payload - I need to iterate through complete payload received from GET call, and remove the information I'll retrieve through entitlement from  removeAccess Task.

could you please help me how do we iterate through a response inside 2nd call? any reference example if available.?

 

Below is the reference Payload I will get through GET call:

 

{

"id": "1234556",
"userName": "xxxxx_TestUser02@xxxx.com",
"name": {
"familyName": "xxxxxxxx",
"givenName": "TestUser"
},
"photos": [
{
"value": ""
}
],
"active": true,
"locale": "EN_US",
"globalAttributes": {
"partnerCustomProperties": {
"57a31194e4b0fac51234bee": [
"Customer Crisis,
"Decitot",
"Demoniation",
"Comaptive",
"innovise"
]
},

},
"clientAttributes": [
{
"clientId": 1234,
"userType": "userType",
"phoneNumbers": [
{}
],
"clientCustomProperties": {
"5b1e7b92345174f83d4981a": [
"All Roles",
"Global Roles"
]
}
},
{
"clientId": 5678,
"userType": "userType2",
"phoneNumbers": [
{}
],
"businessCategory": "CORPORATE",
"userGroupIds": [
"1234e23e4b07536e59f65ef"
],
"clientCustomProperties": {
"1234b9be4b05556072f9ce8": [
"Client Agent"
]
}
}
],
"meta": {
"resourceType": "User",
"createdTime": "2023-08-08 14:33:18",
"lastModified": "2023-08-09 13:37:10"
},
"emails": [
{
"value": "xxxx_TestUser02@xxxxxxx.com",
"primary": true
}
]
}

[Post edited by moderator to mask domain name]

3 REPLIES 3

SB
Saviynt Employee
Saviynt Employee

You can refer to the below link for sample of the JSON. 

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


Regards,
Sahil

vinitamulchanda
New Contributor II
New Contributor II

Thanks Sahil, when I configure the suggested code from above forum:

Thanks Sahil, when I configure the suggested code from above forum:

 

\"Roles\":[${List roleNameList = response.name_of_call1.message.User.Roles.collect{it.toString()}; roleNameList.remove(entitlementValue.entitlement_value.toString());String rolesStr = roleNameList.toString().replace('[','').replace(']','').replace('\"','');return rolesStr;}]

 

It does not compiles well in connector, gives me invalid JSON error. could you please help me with this how do validate what exactly the error would be?

\"Roles\":[${List roleNameList = response.name_of_call1.message.User.Roles.collect{it.toString()}; roleNameList.remove(entitlementValue.entitlement_value.toString());String rolesStr = roleNameList.toString().replace('[','').replace(']','').replace('\"','');return rolesStr;}]

 

I am getting error my JSON validation.

Can you share the complete JSON you created.


Regards,
Sahil