Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

REST - Issue with RemoveAccessJson

piyushm
Regular Contributor II
Regular Contributor II

Hello,

For removing group for a user , I need to call update API and pass the existing members of the group after removing the user from the list. I am making 2 calls, 1st to get the group details and 2nd to update the group. Now, even though I am using responseList.remove(account.accountID) in the 2nd call, I can see in the webservice call the accountId is not getting removed from the responselist.

I tried hardcoding responseList.remove('511') but still the account id is part of the final call.

From the logs:

Calling Webservice Url - https://*****/api/v1/scim/Groups/103 with httpParams - [schemas:[urn:ietf:params:scim:schemas:core:2.0:Group], members:[[value:504], [value:511]]] 

 

RemoveAccessJson

"call": [
{
"name": "Groups",
"connection": "userAuth",
"url": "https://*****/api/v1/scim/Groups/${entitlementValue.entitlementID}",
"httpMethod": "GET",
"httpParams": "",
"httpHeaders": {},
"httpContentType": "application/json",
"successResponses": {
"statusCode": [
200
]
},
"unsuccessResponses": {
"statusCode": [
400,
401
]
}
},
{
"name": "Groups",
"connection": "userAuth",
"url": "https://*****/api/v1/scim/Groups/${entitlementValue.entitlementID}",
"httpMethod": "PUT",
"httpParams": "{\"schemas\": [\"urn:ietf:params:scim:schemas:core:2.0:Group\"],\"members\":${List rolesList = new ArrayList();List responseList = response.Groups1.message.members.collect{it.id};if(response?.Groups1?.message?.members.id==null){return rolesList;}else{responseList.remove(account.accountID);int count=0;int size = responseList.size();for(String str: responseList){count++;rolesList.add('{\"value\":\"'+str+'\"}');if(count == size){return rolesList;}}}}}",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"successResponses": {
"statusCode": [
200,400
]
},
"unsuccessResponses": {
"statusCode": [
400,
401,409
]
}
}

Please let me know if there is any issue with the 2nd call.

3 REPLIES 3

rushikeshvartak
All-Star
All-Star

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


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

piyushm
Regular Contributor II
Regular Contributor II

@rushikeshvartak - I followed the same example given by @shivmano. But my use case is to remove the account from the group instead of removing entitlement value. Now, the account ID is a number and it seems the "remove" method takes the input as index rather than the value if given directly. So, responseList.remove(accountID) transaltes to .remove(511), which i believe is not found because there is no index with value as 511.

So somehow I need to convert it to index. I tried as -- int pos=indexof(511) ; responseList.remove(pos). This works perfectly with static values. But then when i use variables --> int pos= indexof(account.accountID); remove(pos) then I get unexpected token $. 

Somehow I need to get index of accountID and then use that inside the remove method. Let me know if you see any way to do this.

Dhruv_S
Saviynt Employee
Saviynt Employee

Hi @piyushm 

Please refer to the REST Connector's developer handbook. There is step by step instructions on how to construct RemoveAccessJSON. Please validate in postman first before constructing the JSON.

Examples for JSON Construction (saviyntcloud.com)

Regards,

Dhruv Sharma