We are delighted to share our new EIC Delivery Methodology for efficiently managing Saviynt Implementations and delivering quick time to value. CLICK HERE.

Condition based call in REST connector

Nimesh
New Contributor II
New Contributor II

Hello Team,

We have a requirement to handle multiple API calls based on the condition. For example, if the user's start date is in the future then we want to trigger call 1 and call 2 else we want to trigger only call 2. 

Do we have the syntax to have a condition before the call to execute call 1 or call 2 based on the start date?

Please advise.

Thank you!

Regards,

Nimesh

5 REPLIES 5

SB
Saviynt Employee
Saviynt Employee

I have used condition previously to make 2nd call based on the response received for 1st call but not the same use case you want to achieve. Below is the one i used, you can try to use it and see if it works.

"connection": "${response.call1.message.data.errors[0].errorMessage == 'The user already exists.'?'acctAuth':''}",

For your scenario it would be something as below. And since you have to make the 2nd call in both scenarios, you only need to use this in call1.

"connection": "${user.attribute == 'value'?'acctAuth':''}",


Regards,
Sahil

Saviynt_Savvy
Regular Contributor
Regular Contributor

Hi, @SB 
My use case is also similar, where I make 
call1  incase of add account task generating 1 ticket in jira,
call2 & call3 incase of remove account task generating 2 tickets in jira (1 ticket for remove account & 1 ticket for remove access along with the remove account ticket).

But I want to know how to get the "ticketid" of each call, so that each task in saviynt will have  the ticket number.

Here is the JSON, I'm using for this multiple call scenario:
{
"call": [
{
"name": "call1",
"connection": "${task.tasktype==3?'acctAuth':''}",
"url": "https://abcxyz.atlassian.net/rest/api/3/issue",
"httpMethod": "POST",
"httpParams": "{\"fields\": {\"project\":{\"key\":\"GHJ\"},\"summary\": \"add account\",\"issuetype\": {\"name\": \"Task\"},\"reporter\":{\"id\": \"${user.customproperty4}\"}}}",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"ticketidPath":"id",
"unsuccessResponses": {
"message": "Failed"
}
},
{
"name": "call2",
"connection": "${task.tasktype==2 && (allEntitlementsValues==null || allEntitlementsValues.isEmpty() || allEntitlementsValues=='')?'acctAuth':''}",
"url": "https://abcxyz.atlassian.net/rest/api/3/issue",
"httpMethod": "POST",
"httpParams": "{\"fields\": {\"project\":{\"key\":\"GHJ\"},\"summary\": \"remove account\",\"issuetype\": {\"name\": \"Task\"},\"reporter\":{\"id\": \"${user.customproperty4}\"}}}",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"ticketidPath":"id",
"unsuccessResponses": {
"message": "Failed"
}
},
{
"name": "call3",
"connection": "${task.tasktype==2 && (allEntitlementsValues==null || allEntitlementsValues.isEmpty() || allEntitlementsValues=='')?'acctAuth':''}",
"url": "https://abcxyz.atlassian.net/rest/api/3/issue",
"httpMethod": "POST",
"httpParams": "{\"fields\": {\"project\":{\"key\":\"GHJ\"},\"summary\": \"remove access\",\"issuetype\": {\"name\": \"Task\"},\"reporter\":{\"id\": \"${user.customproperty4}\"}}}",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"ticketidPath":"id",
"unsuccessResponses": {
"message": "Failed"
}
}
]
}


Please suggest, how to get the "ticketid" of each call and the same can be seen as 'ticket number' in the tasks generated.

Thank you,
 

SB
Saviynt Employee
Saviynt Employee

You will need to define the ticket number path in each call against "ticketidPath" based on the api response of each call.


Regards,
Sahil

Saviynt_Savvy
Regular Contributor
Regular Contributor

Hi Sahil,
In the JSON I'm using, if you see, I've mentioned the "ticketidPath=id" in each call.
If that is not the way to mention them, please provide how to define the condition check.

Thank you.

ravikumarghr
New Contributor II
New Contributor II

Have you tried using callCondition, below is the sample code

{
"call": [
{
"name": "call1",
"connection": "auth",
"url": "URL",
"httpMethod": "PUT",
"httpParams": "{YOUR PARAMS}",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"callCondition": "${user.customproperty3 != null}",
"successResponses": {
"statusCode": [
200,
201,
204
]
}
},
{
"name": "call2",
"connection": "auth",
"url": "URL",
"httpMethod": "PUT",
"httpParams": "{YOUR PARAMS}",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"successResponses": {
"statusCode": [
200,
201,
204
]
}
}
]
}