Skip to main content
Question

How can I print a ticket out through API?

  • February 19, 2025
  • 2 replies
  • 36 views

ZhengTzer
Apprentice
Forum|alt.badge.img

Hi Team,

 

 

I need to know how to download a ticket through API, currently user click on “print” and save as pdf

the URL would be like this “https://helpdesk.ABC.com/a/tickets/12345/print

 

unable to locate any API related to download or print a ticket

 

 

please advise

Jonathan

2 replies

Forum|alt.badge.img+7
  • Top Contributor ⭐
  • February 19, 2025

As far as i know Freshservice does not have a direct API to download or print a ticket as a PDF.
If it is possible please someone correct me.
 However, you can achieve this using the following approaches:

Option 1: Use Headless Browser Automation (Recommended)

Since Freshservice provides a printable view (/print URL), you can use a headless browser (like Puppeteer or Selenium) to programmatically open the URL and save it as a PDF.

Example using Puppeteer (Node.js)

 

javascript

CopyEdit

const puppeteer = require('puppeteer'); (async () => { const ticketId = "12345"; // Change this dynamically const url = `https://helpdesk.ABC.com/a/tickets/${ticketId}/print`; const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto(url, { waitUntil: 'networkidle2' }); await page.pdf({ path: `ticket_${ticketId}.pdf`, format: 'A4' }); await browser.close(); console.log(`Ticket ${ticketId} saved as PDF.`); })();

  • You must be authenticated before accessing the page. Use session cookies or login automation.

Option 2: Use Third-Party Screenshot API

If you don’t want to use Puppeteer, you can use services like:

These can take a screenshot of the ticket’s print page and convert it into a PDF.

Option 3: Manually Generate a PDF from Ticket Data

  1. Use Freshservice API to get ticket details:

    GET /api/v2/tickets/{ticket_id}

  2. Format the ticket data into an HTML template.
  3. Use a library like wkhtmltopdf or jsPDF to generate a PDF from the HTML content.

    Hope one of these might help you out

ZhengTzer
Apprentice
Forum|alt.badge.img
  • Author
  • Apprentice
  • February 20, 2025

Hi,

 

thanks for your input

tried headless selenium, have to go through company login page and MFA (Zzz...)

 

thanks!

Jonathan