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 updateAccountJson Issue

piyushm
Regular Contributor II
Regular Contributor II

Hello,

 

I have requirement where I need to call update API using updateaccountjson and pass existing entitlements if there is any update to the account attributes.

I tried below but it always sends roles :[null] even though the first call is getting roles in the response. It seems it always goes to else block. The same if condition works correctly in the addaccess/removeaccess jsons. Please let me know if there is way to achieve this or if this is not supported in UpdateAccountJson.

 

{ "call": [ { "name": "Roles", "connection": "userAuth", "url": "https://*****/v1/am/user?email=${account.accountID}", "httpMethod": "GET", "httpParams": "", "httpHeaders": {}, "httpContentType": "application/json", "successResponses": { "statusCode": [ 200 ] }, "unsuccessResponses": { "statusCode": [ 400, 401 ] } }, { "name": "Roles", "connection": "userAuth", "url": "https://*****/v1/am/user", "httpMethod": "PUT", "httpParams": "{\"email\": \"${account.accountID}\",\"firstName\": \"${user.firstname}\",\"lastName\": \"${user.lastname}\",\"isActive\": \"true\",\"phone\": \"${user?.phonenumber}\",\"roles\": [${if(response?.Roles1?.message?.roles!=null) {List roleNameList = response.Roles1.message.roles.collect{it.toString()};String rolesStr = roleNameList.toString().replace('[','').replace(']','').replace('\"','');return rolesStr;}}]}", "httpHeaders": { "Authorization": "${access_token}" }, "httpContentType": "application/json", "successResponses": { "statusCode": [ 200 ] }, "unsuccessResponses": { "statusCode": [ 400, 401 ] } } }

 

If I try with size() in if condition then it fails with error unrexognized token $

{ "call": [ { "name": "Roles", "connection": "userAuth", "url": "https://******/v1/am/user?email=${account.accountID}", "httpMethod": "GET", "httpParams": "", "httpHeaders": {}, "httpContentType": "application/json", "successResponses": { "statusCode": [ 200 ] }, "unsuccessResponses": { "statusCode": [ 400, 401 ] } }, { "name": "Roles", "connection": "userAuth", "url": "https://*****/v1/am/user", "httpMethod": "PUT", "httpParams": "{\"email\": \"${account.accountID}\",\"firstName\": \"${user.firstname}\",\"lastName\": \"${user.lastname}\",\"isActive\": \"true\",\"phone\": \"${user?.phonenumber}\",\"roles\": [${if(response?.Roles1?.message?.roles.size()!=0) {List roleNameList = response.Roles1.message.roles.collect{it.toString()};String rolesStr = roleNameList.toString().replace('[','').replace(']','').replace('\"','');return rolesStr;}}]}", "httpHeaders": { "Authorization": "${access_token}" }, "httpContentType": "application/json", "successResponses": { "statusCode": [ 200 ] }, "unsuccessResponses": { "statusCode": [ 400, 401 ] } } ] }

 

2 REPLIES 2

rushikeshvartak
All-Star
All-Star

In update account json instead of roles1 give call name


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

Superb. That worked. Thanks @rushikeshvartak