Click HERE to see how Saviynt Intelligence is transforming the industry. |
11/01/2023 07:52 AM
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
11/02/2023 02:26 PM
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':''}",
11/08/2023 09:25 PM - edited 11/08/2023 09:45 PM
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,
11/09/2023 08:45 AM - edited 11/09/2023 08:45 AM
You will need to define the ticket number path in each call against "ticketidPath" based on the api response of each call.
11/12/2023 05:27 AM
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.
11/09/2023 09:03 AM
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
]
}
}
]
}