and more in a single search tool across platforms. Read the announcement here. |
04/08/2024 04:45 AM
In the below JSON, all the if-else conditions are working perfectly except the "workspace_id" condition. How to do the condition check in the below JSON at workspace_id
The error in the "view" option of Pending Tasks is :
"{"description":"Validation failed","errors":[{"field":"workspace","message":"The value provided is of type String.It should be one of these values: '2,1,3'","code":"datatype_mismatch"}]};Ticket Number=null;"
CreateTicketJSON:
{
"call": [
{
"name": "call1",
"connection": "acctAuth",
"url": "https://xxxxxxxxx.freshservice.com/api/v2/tickets",
"httpMethod": "POST",
"httpParams": "{\"subject\":\"${if(task.tasktype==3 && task.source=='ZERODAY'){'Onboard Account Ticket:'+user.username+'_'+user.startdate.format(\"MMMM dd yyyy\")} else if(task.tasktype==1 && task.source=='ZERODAY'){'Onboard Acces Ticket:'+user.username+'_'+user.startdate} else if (task.tasktype==1 && task.source=='REQUEST'){'ARS Add Access: '+user.username} else if (task.tasktype==2 && task.source=='REQUEST'){'ARS Remove Access: '+user.username} else{''}}\",\"email\":\"xxxxxxx@abcd.com\",\"description\":\"<div><strong>Name : </strong>${task.accountName}</div><div><strong>Department :</strong>${user.departmentname}</div><div><strong>Email :</strong> ${user.customproperty5}</div><div><strong>Endpoint :</strong> ${task.endpoint}</div><div><strong>Requested Entilements:</strong> ${allEntitlementsValues.replace('ADD :: ','').replace('REMOVE :: ','').replace('\n','').replace('(','').replace(')','')}</div>\",\"priority\": 1, \"status\": 2,\"workspace_id\":\"${if(task.endpoint=='FreshService_Ticketing_EP') {'3'} else{''}}\"}",
"httpHeaders": {
"contentType": "application/json",
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"ticketidPath": "ticket.id",
"unsuccessResponses": {
"message": "Failed"
}
}
]
}
Thanks & Regards,
SaviyntSavvy
Solved! Go to Solution.
04/08/2024 05:11 AM
Disclaimer - This is an AI generated response, the feedback in this thread will be used to fine tune. The generated answer may be wrong, please check the accuracy.
The error you're encountering with the "workspace_id" condition in your JSON seems to relate to the handling of the condition and the type of value expected by the API. Specifically, the API expects a numerical ID for workspace_id, but your condition is providing it as a string, which might not be correctly interpreted or accepted by the API.
Given the error message, it appears the API expects workspace_id to be one of the numeric values (1, 2, or 3) instead of a string. To ensure the condition correctly applies and the workspace_id is sent in the acceptable format, we need to ensure that numeric values are being used without quotes, thus directly passing the numbers instead of string representations.
Below is a corrected version of your CreateTicketJSON section with an emphasis on fixing the workspace_id conditional logic:
{
"call": [
{
"name": "call1",
"connection": "acctAuth",
"url": "https://xxxxxxxxx.freshservice.com/api/v2/tickets",
"httpMethod": "POST",
"httpParams": "{\"subject\":\"${if(task.tasktype==3 && task.source=='ZERODAY'){'Onboard Account Ticket:'+user.username+'_'+user.startdate.format(\"MMMM dd yyyy\")} else if(task.tasktype==1 && task.source=='ZERODAY'){'Onboard Acces Ticket:'+user.username+'_'+user.startdate} else if (task.tasktype==1 && task.source=='REQUEST'){'ARS Add Access: '+user.username} else if (task.tasktype==2 && task.source=='REQUEST'){'ARS Remove Access: '+user.username} else{''}}\",\"email\":\"xxxxxxx@abcd.com\",\"description\":\"<div><strong>Name : </strong>${task.accountName}</div><div><strong>Department :</strong>${user.departmentname}</div><div><strong>Email :</strong> ${user.customproperty5}</div><div><strong>Endpoint :</strong> ${task.endpoint}</div><div><strong>Requested Entilements:</strong> ${allEntitlementsValues.replace('ADD :: ','').replace('REMOVE :: ','').replace('\n','').replace('(','').replace(')','')}</div>\",\"priority\": 1, \"status\": 2,\"workspace_id\":\"${if(task.endpoint=='FreshService_Ticketing_EP') {'3'} else{''}}\"}",
"httpHeaders": {
"contentType": "application/json",
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"ticketidPath": "ticket.id",
"unsuccessResponses": {
"message": "Failed"
}
}
]
}
04/08/2024 07:17 PM
{
"call": [
{
"name": "call1",
"connection": "acctAuth",
"url": "https://xxxxxxxxx.freshservice.com/api/v2/tickets",
"httpMethod": "POST",
"httpParams": "{\"subject\":\"${if(task.tasktype==3 && task.source=='ZERODAY'){'Onboard Account Ticket:'+user.username+'_'+user.startdate.format(\\\"MMMM dd yyyy\\\")} else if(task.tasktype==1 && task.source=='ZERODAY'){'Onboard Access Ticket:'+user.username+'_'+user.startdate} else if (task.tasktype==1 && task.source=='REQUEST'){'ARS Add Access: '+user.username} else if (task.tasktype==2 && task.source=='REQUEST'){'ARS Remove Access: '+user.username} else{''}}\",\"email\":\"xxxxxxx@abcd.com\",\"description\":\"<div><strong>Name : </strong>${task.accountName}</div><div><strong>Department :</strong>${user.departmentname}</div><div><strong>Email :</strong> ${user.customproperty5}</div><div><strong>Endpoint :</strong> ${task.endpoint}</div><div><strong>Requested Entitlements:</strong> ${allEntitlementsValues.replace('ADD :: ','').replace('REMOVE :: ','').replace('\\n','').replace('(','').replace(')','')}</div>\",\"priority\": 1, \"status\": 2,\"workspace_id\":${if(task.endpoint=='FreshService_Ticketing_EP') {'\"3\"'} else{''}}}",
"httpHeaders": {
"contentType": "application/json",
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"ticketidPath": "ticket.id",
"unsuccessResponses": {
"message": "Failed"
}
}
]
}