webinarAttend our Q3 feature roundup webinar on November 21, 2019 Save your Seat

Start a new topic

Can you export or backup knowledge base solutions?

Is it possible to export the knowledge base solutions? We are keen to populate the knowledge base but then we would be vulnerable if we can't keep a backup of the information.


1 person likes this idea

I don't think it is currently possible in the UI. However I believe that Freshservice are planning some updates to the solutions module this year, so potentially this will be looked at.


It is possible if you use the API:


Export folders, one at a time: https://api.freshservice.com/#view_all_solution_article


or to export everything at once you could iterate over categories and folders and then make the previously mentioned api call per folder/category pair: https://api.freshservice.com/#view_all_solution_category


Once you can do this, it would be very easy to schedule as needed.


1 person likes this

Thanks Matthew - I'll give it a try.  
As long as I can get the solutions backed up somehow then I feel happier to commit to putting them all in Freshservice!

   Try this:

$api_key = "API_KEY"

$helpdesk_url = 'https://HELPDESK_URL.freshservice.com'

function normalizePath
{
  param (
    [string]$path
  )
  return $path.Split([IO.Path]::GetInvalidFileNameChars()) -join '_'
}
$solutions = @()

$EncodedCredentials = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $api_key, $null)))
$HTTPHeaders = @{ }
$HTTPHeaders.Add('Authorization', ("Basic {0}" -f $EncodedCredentials))
$HTTPHeaders.Add('Content-Type', 'application/json')
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12

$url = $helpdesk_url + '/solution/categories.json'
$response = Invoke-WebRequest -Uri $url -Headers $HTTPHeaders | ConvertFrom-Json

$response | ForEach-Object {
  $_category = $_.category.name
  $_.category.folders
} | Select-Object id, category_id, name | ForEach-Object {
  $_url = $helpdesk_url + '/solution/categories/' + $_.category_id + '/folders/' + $_.id + '.json'
  Write-Host $_url
  $categoryResponse = Invoke-WebRequest $_url -Headers $HTTPHeaders | ConvertFrom-Json
  $categoryResponse.folder.articles | ForEach-Object {
    $_folder = $categoryResponse.folder.name
    write-host "Backing up: $($_.title)"
    $solutions += [pscustomobject]@{title = $_.title; content = $_.description; category = $_category; folder = $_folder }
  }
}

$solutions | ForEach-Object {
  $title = normalizePath($_.title)
  $category = normalizePath($_.category)
  $folder = normalizePath($_.folder)
  $path = ".\$category\$folder\"
  if (!(Test-Path $path))
  {
    New-Item -Path $path -ItemType Directory
  }
  $_.content | Out-File -FilePath ($path + "$title.html")
} 

   This is a Powershell script which will export all solutions to html files in the folder structure .\<category name>\<folder name>\<article name>.html


Replace the url and api key placeholders with your own details. Note that embedded media (images,etc ) as well as attachments aren't downloaded so these would need to be exported manually as far as I can tell.

Login or Signup to post a comment
JS Bin