API - Get tickets with Parent/Child tickets


I want to get all details about a ticket including the related tickets. The documentation propose to execute this link api/v2/tickets/[id]?include=related_tickets but it will so long to execute it for each ticket after getting all details with this /api/v2/tickets’

Is there another field that will help me to get information about related tickets in the result of this API /api/v2/tickets’

Best regards

Hi Omar,

The documentation was a bit lacking on this. There is includes that can be used with full list queries and then includes that can only be done by Id.

‘requester’, ‘stats’, ‘tags’, ‘requested_for’, ‘department’

By Id:
‘tags’, ‘conversations’, ‘requester’, ‘stats’, ‘problem’, ‘assets’, ‘change’, ‘related_tickets’, ‘requested_for’, ‘department’, ‘feedback’

As you said, you would get all tickets to get the ids and then loop through those tickets to run the include query. Guessing that the relationships are stored on a separate object requiring a subquery to get the related tickets. With that said, also keep in mind that may count as multiple API calls to get relationships, but have not watched to see if the limit is affected when making the embedded call.

We released a Powershell module ( PowerShell Gallery | FreshservicePS 0.1.3) to make this more simple, although it still will take time to make the Id API call for each ticket and you could hit throttle limits. The module also has a built in throttling in it detects you are getting close to hitting throttle limits:

Here is a sample code to get tickets and then loop to get related tickets and tags (you can do multiple embed\includes at once)

$tickets = Get-FSTicket

$relTickets = foreach ($ticket in $tickets) {
    Get-FSTicket -id $ticket.id -include related_tickets,tags

#$relTickets var has the data, you can export it or perform queries against the data.
#Keep in mind, if you are exporting, the data needs to be manipulated (e.g. arrays to strings) prior to export.
#$relTickets | Export-Csv -Path C:\TicketswRelationships.csv -NoTypeInformation
#$relTickets | Where{$_.