Extracting all yesterdays tickets on Fresh Desk using API

Hi!


I am unable to extract all tickets that were created yesterday or updated yesterday.

I am using the api token .


Queries that i have tried but failed are


This query returns all the tickets

"https://"+ domain +".freshdesk.com/helpdesk/tickets/filter/all_tickets?format=json&updated_since=2017-10-05&page=[pageno]", auth = (api_key, password))


This query returns error code 400

"https://'+ domain +'.freshdesk.com/api/v2/search/tickets?query="created_at:2017-10-05T00:00:00Z"', auth = (api_key, password))



Can anyone please help me with the correct query


Hello Mohammed,


Can you please try using this query to obtain the ticket list that were updated yesterday?


https://domain.freshdesk.com/api/v2/tickets?updated_since=2017-10-05T02:00:00Z


Cheers!

Hi Aravind!


Thanks for your reply, However your query returns only 35 columns and 30 rows. Im interested in getting all the tickets and columns.


Here is the code i wrote in python to extract and return all tickets, but after running this one i need to run a new script which would extract only yesterdays tickets and not all.


i=0

while(True):

    try:

        #print("IN TRY")

        r = requests.get("https://"+ domain +".freshdesk.com/helpdesk/tickets/filter/all_tickets?format=json&page="+str(i), auth = (api_key, password)) 

        json_data=r.json()

        if(i==0):

            print("First Statement executed")

            Ticket_Table=json_normalize(json_data)

        else:

            Ticket_Table = pd.concat([Ticket_Table,json_normalize(json_data)],axis=0,ignore_index=True)

            Ticket_Table['created_at'].shape

        i=i+1

        print("I counter : "+str(i))

        time.sleep(150)

    except :

        print("Exception occured!")

        Ticket_Table.to_csv("Datatill"+str(i)+".csv") 

        break

Hi Mohammed,


You can probably use the per_page and page parameters to increate the list of results that is returned. You can read more about them here : Pagination


Cheers!

Login or Signup to post a comment