5

I'm currently working with the osTicket API to realize a ticket-system on my website. I already found a way to create tickets with the downloaded example for the osTicket API. But now, I need to get the ticket information via the API, so I can display answers of the ticket on my website. I searched a lot of hours on google but can't find any example or any API references to get ticket informations from the API. Anybody have some code examples or links for me? I really tried my best to find any help on the internet but found nothing.. Best reagards Leif

duncan
  • 31,401
  • 13
  • 78
  • 99
Leif Paisen
  • 51
  • 1
  • 3

3 Answers3

4

We have the same issue at our business.so, we expanded API functions to manage ticket operations as :

  • retrieve ticket details.
  • get list of tickets issued by one user.
  • get list of tickets assigned to an agent (staff member).
  • post a reply message to one ticket with updated status. i.e. change ticket status from open to closed.

[APIs implementaion] https://github.com/osTicket/osTicket/pull/4361/files

Amal Magdy
  • 177
  • 1
  • 4
1
SELECT ticket_id,
       t.number, 
       t.ticket_id, 
       address, 
       Ifnull(Concat(st.firstname, ' ', st.lastname), 'No Assignee') assigned, 
       subject, 
       t.created, 
       t.updated ticket_updated, 
       t.isoverdue 
FROM ost.`ost_ticket` t 
INNER JOIN ost.ost_ticket__cdata USING(ticket_id) 
LEFT JOIN ost.ost_user_email USING (user_id) 
LEFT JOIN ost.ost_user ou ON ou.id = t.user_id 
LEFT JOIN ost.ost_staff st USING (staff_id) 
WHERE t.status_id = '1' AND ( t.isanswered = 0 OR t.isoverdue = 1 )

for OS ticket 1.10 I have tested

alex.pulver
  • 2,107
  • 2
  • 31
  • 31
Vinit M
  • 11
  • 1
  • Can you also make a pull request to update the docs according to your API updates? or is it documented somewhere how to use? – Meir Apr 06 '22 at 14:40
0

I simply made a script to get the needed value directly from the ticket mysql database.

SELECT ticketid, 
   t.ticket_id, 
   address, 
   Ifnull(Concat(st.firstname, ' ', st.lastname), 'No Assignee') assigned, 
   subject, 
   t.created, 
   t.updated 
   ticket_updated, 
   t.isoverdue 
FROM   ost.`ost_ticket` t 
   INNER JOIN ost.ost_ticket__cdata USING(ticket_id) 
   LEFT JOIN ost.ost_user_email USING (user_id) 
   LEFT JOIN ost.ost_user ou 
          ON ou.id = t.user_id 
   LEFT JOIN ost.ost_staff st USING (staff_id) 
WHERE  t.status = 'Open' 
   AND ( t.isanswered = 0 
          OR t.isoverdue = 1 ) 

This I then format as json, but I leave that as an exercise to the reader ;-)

Leif Neland
  • 1,416
  • 1
  • 17
  • 40