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

Unexpected character ('r' (code 114)): was expecting comma to separate Array entries

Amar_Simha
Regular Contributor
Regular Contributor

Hi Team,

I am trying to build add Access JSON with two API calls to send out all entitlements to add roles to the user. 

Based on the reference, I was able to build sample JSON to create an Array List that the API expects.

Can anyone please advise on what is missing here? We are running on some tight timelines, really appreciate the quick support.

Below is the code and from logs, I am getting "Unexpected character ('r' (code 114)): was expecting comma to separate Array entries" error. 

 

 

"httpParams": "{\"roles\":[\"${if(response?.Roles1?.message?.roles==null or response?.Roles1?.message?.roles==[] or response?.Roles1?.message?.roles=='') {entitlementValue.entitlement_value} else {List rolesList = new ArrayList();List responseList = response.Roles1.message.roles.collect{it.role_name};if(responseList?.size() == 0){return rolesList;}else{responseList.add(entitlementValue.entitlement_value);int count=0;int size = responseList.size();for(String str: responseList){count++;rolesList.add(','{\"role_name\":\"'+str+'\"}',');if(count == size){return rolesList;}}}}}\"]}",
 
Expected JSON would be in format
 
{
"roles": [
{
"role_name": "<Role Name>"
}
]
}
10 REPLIES 10

rushikeshvartak
All-Star
All-Star

Share full json and logs


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

@rushikeshvartak : Please find the attached details. I have only shared required logs as it had sensitive information.

Does entitlement  Type name is Roles1 and Roles2


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

@rushikeshvartak : There is only one Entitlement Type named "Roles"

Amar_Simha
Regular Contributor
Regular Contributor

@rushikeshvartak : Did you get a chance to review the issue?

NM
Honored Contributor III
Honored Contributor III

Hi @Amar_Simha , does API expects all existing entitlement to be send?


If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'

Amar_Simha
Regular Contributor
Regular Contributor

@NM : Yes, that is correct.

Amar_Simha
Regular Contributor
Regular Contributor

@rushikeshvartak @NM : I was able to resolve the issue. Thanks for the support.

NM
Honored Contributor III
Honored Contributor III

Hi @Amar_Simha , can you share the json it will be helpful for other having same problem.


If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'

Amar_Simha
Regular Contributor
Regular Contributor

@NM @rushikeshvartak : This is the working logic. Thanks.

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