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

Rest Connector Create Account JSON - IF/Else using Dynamic Attribute

gauravchandok
Regular Contributor
Regular Contributor

Dear all,

I am trying to create account on Zoho Projects application where a user is selecting Rolename in access request Dynamic attribute.

Now based on the rolename selected in dynamic attribute I need to send role id to the REST API.

I tried creating user without any dynamic attribute and all role id and email information as fixed value in createAccountJSON and it worked fine.. then I modified my createAccountJSON to adjust based on value selected in dynamic attribute and request is failing.

Kindly go through them and let me know where I am doing wrong.

Thanks

Working JSON:

{
"accountIdPath":"call1.message.users.zpuid",
"call":[
{
"name":"call1",
"connection":"acctAuth",
"url":"https://projectsapi.zoho.in/restapi/portal/60019805102/users/ ?email=pawan.kumar@test.com&roleid=155720000000031037&profileid=155720000000029551 ",
"httpMethod":"POST",
"httpHeaders":{
"Authorization":"${access_token}"
},
"unsuccessResponses":{
"error.message":"Operation Failed",
"error.message":"General Error"
}
}
]
}

JSON with if else and Dynamic attribute : ERROR

{
"accountIdPath":"call1.message.users.zpuid",
"call":[
{
"name":"call1",
"connection":"acctAuth",
"url":"https://projectsapi.zoho.in/restapi/portal/60019805102/users/?email=${user.email}&roleid=${if(requestAccessAttributes.get('RoleName')=='Test'){'155720000000033008'} else if(requestAccessAttributes.get('RoleName')=='Test1'){'155720000000033009'} else{'155720000000028005'}}&profileid=155720000000029551",
"httpMethod":"POST",
"httpHeaders":{
"Authorization":"${access_token}"
},
"unsuccessResponses":{
"error.message":"Operation Failed",
"error.message":"General Error"
}
}
]
}

8 REPLIES 8

Darshanjain
Saviynt Employee
Saviynt Employee

 Instead of if else , use this

${requestAccessAttributes.get('RoleName') == 'Test' ? '155720000000033008 ' : '155720000000028005'}

Hi Darshan,

We have multiple if elseif else conditions so cannot use your suggestion.. I will update my question accordingly.

 

Thanks

The above if else should also work generally, What is the error you are getting or you are getting null values, Also try once with the above condition which i have given and see if you are getting the values correctly there just to see there is no issue with DA values

gauravchandok
Regular Contributor
Regular Contributor

Hi Darshan,

I tried the below json and it also failed for me.. Not able to get the log details as logs are not loading in our environment.

 

{
"accountIdPath":"call1.message.users.zpuid",
"call":[
{
"name":"call1",
"connection":"acctAuth",
"url":"https://projectsapi.zoho.in/restapi/portal/60019805102/users/?email=${user.email}&roleid=${requestAccessAttributes.get('RoleName ') == 'Test' ? '155720000000033008' : '155720000000028005'}&profileid=155720000000029551",
"httpMethod":"POST",
"httpHeaders":{
"Authorization":"${access_token}"
},
"unsuccessResponses":{
"error.message":"Operation Failed",
"error.message":"General Error"
}
}
]
}

 

Thanks

If the logs are not loading , i would prefer you to raise a ticket in FD and get that working so that it is easy to check in logs if the values are populating or not.

Also as  @adriencosson said , once logs are working in the config json you can put showlogs=true so that you can troubleshoot where you are going wrong

adriencosson
Valued Contributor
Valued Contributor

Hello,

To help you troubleshoot the issue, you can set the below Json in ConfigJSON parameter of your connector : 

{"showLogs":true}

This way you would get the appropriate logs.

Also, you might give a try with the following naming convention : reqAttrs that is also available to get Dynamic Attributes in REST Connector.

Regards,
Adrien COSSON

Dears,

I was creating the json correctly but there was some issue in my roleid thats why account creation was failing..
Below is the working json.

{
"accountIdPath":"call1.message.users.zpuid",
"call":[
{
"name":"call1",
"connection":"acctAuth",
"url":"https://projectsapi.zoho.in/restapi/portal/60019805102/users/?email=${user.email}&roleid=${if(requestAccessAttributes.get('RoleName')=='Test'){'155720000000031037 '} else{'155720000000028005'}}&profileid=155720000000029551",
"httpMethod":"POST",
"httpHeaders":{
"Authorization":"${access_token}"
},
"unsuccessResponses":{
"error.message":"Operation Failed",
"error.message":"General Error"
}
}
]
}

Thanks

@gauravchandok  Perfect, As the logic was correct only issue would have been DA value not populating or parameter passing. Good to know that its working now.