Skip to main content

Hello,

New here, I was wondering if it is possible to extract all the data from a ticket utilizing API. I specifically want to see all data in the description fields as well as anything mentioned in notes. Doing a normal export doesn’t provide me with any relevant data beyond name, date/time, etc. 

 

Any help is greatly appreciated. 

I would like to note this is for Fresh service not Fresh desk. Unless they are the same thing?


Hello,

New here, I was wondering if it is possible to extract all the data from a ticket utilizing API. I specifically want to see all data in the description fields as well as anything mentioned in notes. Doing a normal export doesn’t provide me with any relevant data beyond name, date/time, etc. 

 

Any help is greatly appreciated. 

There are no export per say, you need to do it ticket by ticket. keep in mind there are a rate limit on how many calls per minute you can do. 
https://api.freshservice.com/v2/#view_a_ticket
 


Hello,

New here, I was wondering if it is possible to extract all the data from a ticket utilizing API. I specifically want to see all data in the description fields as well as anything mentioned in notes. Doing a normal export doesn’t provide me with any relevant data beyond name, date/time, etc. 

 

Any help is greatly appreciated. 

There are no export per say, you need to do it ticket by ticket. keep in mind there are a rate limit on how many calls per minute you can do. 
https://api.freshservice.com/v2/#view_a_ticket
 

So, there wouldn’t be a way to do an API call for all tickets under “change request” for example? I would have to manually do an API call for each change request?


Hello,

New here, I was wondering if it is possible to extract all the data from a ticket utilizing API. I specifically want to see all data in the description fields as well as anything mentioned in notes. Doing a normal export doesn’t provide me with any relevant data beyond name, date/time, etc. 

 

Any help is greatly appreciated. 

There are no export per say, you need to do it ticket by ticket. keep in mind there are a rate limit on how many calls per minute you can do. 
https://api.freshservice.com/v2/#view_a_ticket
 

So, there wouldn’t be a way to do an API call for all tickets under “change request” for example? I would have to manually do an API call for each change request?

Exakt, if you like to get all data for each change/ticket. You can list all changes/tickets but you will only get 10 last notes in tickets but if you need more you need to loop each ticket with the notes endpoint. 


Hello,

New here, I was wondering if it is possible to extract all the data from a ticket utilizing API. I specifically want to see all data in the description fields as well as anything mentioned in notes. Doing a normal export doesn’t provide me with any relevant data beyond name, date/time, etc. 

 

Any help is greatly appreciated. 

There are no export per say, you need to do it ticket by ticket. keep in mind there are a rate limit on how many calls per minute you can do. 
https://api.freshservice.com/v2/#view_a_ticket
 

So, there wouldn’t be a way to do an API call for all tickets under “change request” for example? I would have to manually do an API call for each change request?

Exakt, if you like to get all data for each change/ticket. You can list all changes/tickets but you will only get 10 last notes in tickets but if you need more you need to loop each ticket with the notes endpoint. 

Alright, one final thing. I would assume I would have to change the ticket ID every time I do a new API call. Otherwise, it would just pull the same tickets over and over?  


Hello,

Welcome! If you're looking to extract all the data from a ticket, including details from description fields and notes, you can indeed use the Freshservice API to achieve this. However, keep in mind that there isn't a bulk export feature available, so you would need to retrieve data ticket by ticket.

You can find the API documentation here: [Freshservice API Documentation (https://api.freshservice.com/v2/#view_a_ticket Be aware of the rate limits on API calls to avoid hitting any restrictions.

If you have any specific questions about using the API or need further assistance, feel free to ask!

I’m running into some 404 errors when running my script strangely. Could this be due to my account not having enough permissions to satisfy the call? I can provide my script here if needed.


So, I got it to somewhat work. Now the issue I am having is that when the PowerShell script is executed the output is blank. Can anyone tell me what I’m doing wrong? Below is the script I’m utilizing:

 

# Define the Freshservice domain
$domain = 'domain'

# API Key
$apiKey = 'my api key'

# API endpoint to retrieve all Service Requests
$endpoint = "https://${domain}/api/v2/tickets?type=Service%20Request"

# Set up headers with API key
$headers = @{
    'Authorization' = 'Basic {0}' -f Convert]::ToBase64String(6Text.Encoding]::ASCII.GetBytes("${apiKey}:x"))
    'Content-Type'  = 'application/json'
}

# Initialize an array to hold all tickets
$allTickets = @()

# Variable to handle pagination (Freshservice uses a 'next_page' key to indicate more data)
$hasMorePages = $true

while ($hasMorePages) {
    # GET request to retrieve all tickets of the specified type
    $response = Invoke-RestMethod -Uri $endpoint -Headers $headers -Method GET -Verbose

    # Add the retrieved tickets to the $allTickets array
    $allTickets += $response.tickets

    # Check if there is a next page
    if ($response.meta.next_page -ne $null) {
        $endpoint = $response.meta.next_page
    } else {
        $hasMorePages = $false
    }
}

# Output the raw response to check what data is returned
Write-Host "Total tickets retrieved: $($allTickets.Count)" -ForegroundColor Yellow

# Filter tickets where the subject contains "Change Request"
$filteredTickets = $allTickets | Where-Object { $_.subject -like "*Change Request*" }


So, I got it to somewhat work. Now the issue I am having is that when the PowerShell script is executed the output is blank. Can anyone tell me what I’m doing wrong? Below is the script I’m utilizing:

 

# Define the Freshservice domain
$domain = 'domain'

# API Key
$apiKey = 'my api key'

# API endpoint to retrieve all Service Requests
$endpoint = "https://${domain}/api/v2/tickets?type=Service%20Request"

# Set up headers with API key
$headers = @{
    'Authorization' = 'Basic {0}' -f Convert]::ToBase64String(6Text.Encoding]::ASCII.GetBytes("${apiKey}:x"))
    'Content-Type'  = 'application/json'
}

# Initialize an array to hold all tickets
$allTickets = @()

# Variable to handle pagination (Freshservice uses a 'next_page' key to indicate more data)
$hasMorePages = $true

while ($hasMorePages) {
    # GET request to retrieve all tickets of the specified type
    $response = Invoke-RestMethod -Uri $endpoint -Headers $headers -Method GET -Verbose

    # Add the retrieved tickets to the $allTickets array
    $allTickets += $response.tickets

    # Check if there is a next page
    if ($response.meta.next_page -ne $null) {
        $endpoint = $response.meta.next_page
    } else {
        $hasMorePages = $false
    }
}

# Output the raw response to check what data is returned
Write-Host "Total tickets retrieved: $($allTickets.Count)" -ForegroundColor Yellow

# Filter tickets where the subject contains "Change Request"
$filteredTickets = $allTickets | Where-Object { $_.subject -like "*Change Request*" }

 

Heyy @Daniel Söderlund - tagging you here for your visibility!


Hello @armani.killings, can you write the contents of $allTickets to see if your array contains any data? I think your issue is how you are trying to paginate. Give this a try and see if it works. Also you are creating a variable $filteredTickets but then you are not using the variable, so I commented that portion out.

 

# Define the Freshservice domain

$domain = 'Domain'

 

# API Key

$apiKey = 'API_KEY'

 

# API endpoint to retrieve all Service Requests

$endpoint = "https://${domain}/api/v2/tickets?type=Service%20Request"

 

# Set up headers with API key

$headers = @{

'Authorization' = 'Basic {0}' -f Convert]::ToBase64String(iText.Encoding]::ASCII.GetBytes("${apiKey}:x"))

'Content-Type' = 'application/json'

}

 

# Initialize an array to hold all tickets

$allTickets = @()

 

# Variable to handle pagination (Freshservice uses a 'next_page' key to indicate more data)

$hasMorePages = $true

 

while ($hasMorePages) {

# GET request to retrieve all tickets of the specified type

$response = Invoke-RestMethod -Uri $endpoint -Headers $headers -Method GET -Verbose -ResponseHeadersVariable responseHeaders

 

# Add the retrieved tickets to the $allTickets array

$allTickets += $response.tickets

 

# Check if there is a next page

if ($responseHeaders.'Link') {

$endpoint = $responseHeaders.'Link'.Split(';')p0].TrimStart('<').TrimEnd('>')

}

else {

$hasMorePages = $false

}

}

 

# Output the raw response to check what data is returned

Write-Host "Total tickets retrieved: $($allTickets.Count)" -ForegroundColor Yellow

 

# Filter tickets where the subject contains "Change Request"

#$filteredTickets = $allTickets | Where-Object { $_.subject -like "*Change Request*" }

 

Hope this helps! It ran on my instance :)


Reply