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

If else REST connector JSON.

Rajatlm10
New Contributor III
New Contributor III

Hi , 

I am using the below if else syntax in REST connector JSOn. even though the task are getting completed but the correct values in condition are not getting picked up. 

Can anyone validate if i am doing it the right way or not ?

{
"call": [
{
"name": "Country",
"connection": "acctAuth",
"url": "https://xyz/Users/${account.customproperty5}",
"httpMethod": "PATCH",
"httpParams": "{\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:PatchOp\"],\"Operations\":[{\"op\": \"add\",\"path\":\"urn:ietf:params:scim:schemas:extension:spend:2.0:Role:roles\",\"value\":[{\"roleName\":\"${requestAccessAttributes?.get('Rolename')}\",\"roleGroups\":[\"if(${${task.entitlement_valueKey.entitlement_value}}=='AUSTRIA') {'[AT-480]'} else if(${task.entitlement_valueKey.entitlement_value}=='Belgium'){'[BE-140]'} else if(${task.entitlement_valueKey.entitlement_value}=='Canada'){'[CA-002]'} else if(${task.entitlement_valueKey.entitlement_value}=='Denmark'){'[DK-200]'} else if(${task.entitlement_valueKey.entitlement_value}=='Finland'){'[FI-230]'} else if(${task.entitlement_valueKey.entitlement_value}=='France'){'[FR-130]'} else if(${task.entitlement_valueKey.entitlement_value}=='Germany'){'[DE-060]'} else if(${task.entitlement_valueKey.entitlement_value}=='Greece'){'[GR-270]'} else if(${task.entitlement_valueKey.entitlement_value}=='Ireland'){'[IE-120]'} else if(${task.entitlement_valueKey.entitlement_value}=='Italy'){'[IT-150]'} else if(${task.entitlement_valueKey.entitlement_value}=='Mexico'){'[MX-170]'} else if(${task.entitlement_valueKey.entitlement_value}=='NL-Venray'){'[NL-070]'} else if(${task.entitlement_valueKey.entitlement_value}=='NL-Holland'){'[NL-071]'} else if(${task.entitlement_valueKey.entitlement_value}=='Norway'){'[NO-080]'} else if(${task.entitlement_valueKey.entitlement_value}=='Portugal'){'[PT-050]'} else if(${task.entitlement_valueKey.entitlement_value}=='Spain'){'[ES-040]'} else if(${task.entitlement_valueKey.entitlement_value}=='Sweden'){'[SE-090]'} else if(${task.entitlement_valueKey.entitlement_value}=='Switzerland'){'[CH-470]'} else if(${task.entitlement_valueKey.entitlement_value}=='United Kingdom'){'[UK-010]'} else if(${task.entitlement_valueKey.entitlement_value}=='US-XBS'){'[US-005]'} else if(${task.entitlement_valueKey.entitlement_value}=='Isreal'){'[IL-310]'} else if(${task.entitlement_valueKey.entitlement_value}=='Malaysia'){'[MY-320]'} else if(${task.entitlement_valueKey.entitlement_value}=='Japan'){'[JP-100]'} else if(${task.entitlement_valueKey.entitlement_value}=='S korea'){'[KR-530]'} else if(${task.entitlement_valueKey.entitlement_value}=='China'){'[CN-340]'} else if(${task.entitlement_valueKey.entitlement_value}=='Hong kong'){'[HK-370]'} \"]}]}]}",
"httpHeaders": {
"Authorization": "${access_token}",
"Accept": "application/json"
},
"httpContentType": "application/json",
"successResponses": {
"statusCode": [
200,
201
]
}
}
]
}

8 REPLIES 8

adriencosson
Valued Contributor
Valued Contributor

Hi @Rajatlm10 ,

The "IF / ELSE" condition must be surrounded by ${ } and all the logic must be contained inside, but you then don't need to use the same to surround the task.entitlement_value.entitlement_value object.

Please find an example below (simplified) :

${if (task.entitlement_valuekey.entitlement_value=='AUSTRIA') {'[AT-480]'} else if if(task.entitlement_valueKey.entitlement_value=='Belgium'){'[BE-140]'} else if () {} ... else {''} }

 Hope this helps.

Regards,
Adrien COSSON

rushikeshvartak
All-Star
All-Star
{
"call": [
{
"name": "Country",
"connection": "acctAuth",
"url": "https://xyz/Users/${account.customproperty5}",
"httpMethod": "PATCH",
"httpParams": "{\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:PatchOp\"],\"Operations\":[{\"op\": \"add\",\"path\":\"urn:ietf:params:scim:schemas:extension:spend:2.0:Role:roles\",\"value\":[{\"roleName\":\"${requestAccessAttributes?.get('Rolename')}\",\"roleGroups\":[\"${if (task.entitlement_valueKey.entitlement_value == 'AUSTRIA') {'[AT-480]'} else if (task.entitlement_valueKey.entitlement_value == 'Belgium') {'[BE-140]'} else if (task.entitlement_valueKey.entitlement_value == 'Canada') {'[CA-002]'} else if (task.entitlement_valueKey.entitlement_value == 'Denmark') {'[DK-200]'} else if (task.entitlement_valueKey.entitlement_value == 'Finland') {'[FI-230]'} else if (task.entitlement_valueKey.entitlement_value == 'France') {'[FR-130]'} else if (task.entitlement_valueKey.entitlement_value == 'Germany') {'[DE-060]'} else if (task.entitlement_valueKey.entitlement_value == 'Greece') {'[GR-270]'} else if (task.entitlement_valueKey.entitlement_value == 'Ireland') {'[IE-120]'} else if (task.entitlement_valueKey.entitlement_value == 'Italy') {'[IT-150]'} else if (task.entitlement_valueKey.entitlement_value == 'Mexico') {'[MX-170]'} else if (task.entitlement_valueKey.entitlement_value == 'NL-Venray') {'[NL-070]'} else if (task.entitlement_valueKey.entitlement_value == 'NL-Holland') {'[NL-071]'} else if (task.entitlement_valueKey.entitlement_value == 'Norway') {'[NO-080]'} else if (task.entitlement_valueKey.entitlement_value == 'Portugal') {'[PT-050]'} else if (task.entitlement_valueKey.entitlement_value == 'Spain') {'[ES-040]'} else if (task.entitlement_valueKey.entitlement_value == 'Sweden') {'[SE-090]'} else if (task.entitlement_valueKey.entitlement_value == 'Switzerland') {'[CH-470]'} else if (task.entitlement_valueKey.entitlement_value == 'United Kingdom') {'[UK-010]'} else if (task.entitlement_valueKey.entitlement_value == 'US-XBS') {'[US-005]'} else if (task.entitlement_valueKey.entitlement_value == 'Isreal') {'[IL-310]'} else if (task.entitlement_valueKey.entitlement_value == 'Malaysia') {'[MY-320]'} else if (task.entitlement_valueKey.entitlement_value == 'Japan') {'[JP-100]'} else if (task.entitlement_valueKey.entitlement_value == 'S korea') {'[KR-530]'} else if (task.entitlement_valueKey.entitlement_value == 'China') {'[CN-340]'} else if (task.entitlement_valueKey.entitlement_value == 'Hong kong') {'[HK-370]'} else {''}}]\"]}]}]}",
"httpHeaders": {
"Authorization": "${access_token}",
"Accept": "application/json"
},
"httpContentType": "application/json",
"successResponses": {
"statusCode": [
200,
201
]
}
}
]
}

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

sherbert
New Contributor
New Contributor

sherbert_0-1721052251184.png

 

Share logs


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

sherbert
New Contributor
New Contributor

How can I share them securely? 

‼️‼️⚠️Keep company-specific private information masked on public forums, such as the name and URL.⚠️‼️‼️


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

adriencosson
Valued Contributor
Valued Contributor

You need to anonymise data to not contain any information from customer.

Regards,
Adrien COSSON

sherbert
New Contributor
New Contributor