and more in a single search tool across platforms. Read the announcement here. |
01/05/2024 12:58 PM
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 ] } } ] }
Solved! Go to Solution.
01/05/2024 04:18 PM
In update account json instead of roles1 give call name
01/05/2024 06:47 PM
Superb. That worked. Thanks @rushikeshvartak