Thank you Sysadmins! Show some love, join a contest, and win $100 USD, you deserve it all. Win $100 USD

Start a new topic
Answered

Api - count of all created tickets

Hi - I already went through the articles that might be related to my problem but couldn't find any solution. 


I simply want to know the count of all created tickets in our support department.

When I'm sending the request https://xxxxxxx.freshservice.com/helpdesk/tickets/view/12345?format=json"


... I only get the first 30 results back. The only possibility I see here is to loop through all pages by using ?page=X - in case the result is again 30 I go with ?page=2 and so on.


The problem here is that I do not know if there is a "next page" if my result is again 30. Could be that there are exact 30 tickets 


But anyway, this isn't really the solution what I am looking for - there must be an easier way since I already see the total count of tickets in the web GUI, in my view!


Maybe I missed something in the Api documentation. help please :-)




Best Answer

You can check to see if you have more pages to return by checking for a returned header. yes you still have to loop and loop but at least you can so some checking


The 'link' header in the response will hold URL of the next page, if it exists. If you have reached the last page of objects, then the link header will not be set.

Headers: 
"link":< https://domain.freshservice.com/api/v2/tickets?filter=all_tickets&page=2>;rel="next"

Unfortunately I believe that is the only way at the moment.


We have hourly exports setup to import into another system for reporting and we ended up using a custom report which exports to csv which is then automatically processed; otherwise the api limit keeps getting hit if we run through all the pages.


There is version 2 of the api in the pipe line I believe... 

@fs Can you comment on rumors of API v.2?!

O.O

Hi All, 

I hope you might have already noticed, if not we have released API V2 

You can access the document by visiting API V2

@Andreas to answer your question, have you tried "URL?format=json&page=1" in the URL, this help you navigate through pages.

Hope this helps, feel free to reach out for any help.


Jayesh
Freshservice Support 

Hi Jayesh,


thanks for your reply.

As I wrote -

The only possibility I see here is to loop through all pages by using ?page=X - in case the result is again 30 I go with ?page=2 and so on.


That means I loop through the pages until I come to the end. Then just simply multiply Nr. of loops * 30. 
but - this is not accurate enough.  

Correct. The v2 API is not very robust.  It would be nice if we could request aggregate numbers. i.e. total tickets, open ticket, closed tickets, etc and then add filtering like 'last 7 days', last month, etc.


1 person likes this

having the ability to do this would make life so much easier!!

Answer

You can check to see if you have more pages to return by checking for a returned header. yes you still have to loop and loop but at least you can so some checking


The 'link' header in the response will hold URL of the next page, if it exists. If you have reached the last page of objects, then the link header will not be set.

Headers: 
"link":< https://domain.freshservice.com/api/v2/tickets?filter=all_tickets&page=2>;rel="next"

Thanks John for your suggestion. 


We do understand that it would be nice to have an API request to get the aggregate numbers like Total number of Tickets created, Open tickets, Closed Tickets. We'll definitely share this feedback to our product team.


In the meantime, if you are looking to use the APIs to integrate with PowerBI or any similar reporting tools, we have scheduled data exports available in Analytics which can be integrated. For more information related to this, please refer to the solution article "Exporting Data from Analytics to Power BI"


Do reach out to our support team at support@freshservice.com if you are having any issues


Thanks,
Rajagopal

Hi, 

Any news here ?  

The Export from Analytics is pretty limited since it can be run only once with the same API key.  

If you could to the export the ability to run it more than once a day it would be fantastic 

Tnx
David 

Login or Signup to post a comment