Getting large data sets with the Zendesk API and Python Follow

Comments

9 comments

  • Avatar
    Viola Rudenko

    Hi Charles,


    Thank you for the great API tutorials! It's super helpful.


    Is there a way to use token for authentication in this setup? I tried to follow the token guidelines here , but it gives me 404 error:


    credentials = 'my_email' + '/token', 'my_api_token'
    session = requests.Session()
    session.auth = credentials


    OR


    user = 'my_email +'/token'
    pwd = 'my_api_key'
    session = requests.Session()
    session.auth = (user, pwd)


    I also tried to set the header like here, but still no luck:


    session = requests.Session()
    head = {'Authorization': 'access_token my_api_token'}
    response = session.get(url, headers=head)


    P.S. I was able to get access to Zendesk data with my email address and token before.

  • Avatar
    Charles Nadeau

    Hi Viola,


    Hmm, I tested the script with a token and it works for me. Example:


    credentials = 'example@outlook.com' + '/token', 'qPbD6eTsXNC4aBIDs4UkHYD3fss6fdfalnZDjmSN'

    Did you check if token access is enabled in your Zendesk? In the agent interface, click Admin (gear icon) in the lower-left, then API in the Channels category. On the Channels/API page, verify that Token Access is enabled (the blue checkbox). If not, make sure to click the Save button after selecting the checkbox.

  • Avatar
    Viola Rudenko

    Hi Charles,


    Thank you for looking into that! The token access was enabled, but looks like I picked incorrect topic_id. As soon as I switched to ticket_metrics, the script executed.

  • Avatar
    Don Wood

    Thanks! this looks very useful. I'm not very technical so excuse my question. Can this work to get all the data on tickets out to a spreadsheet? The reporting in Zendesk is limited and I want to be able to get ticket data our of the system and into a format to build reports. A simple this I would like is to report the ticket and the associated JIRA ticket number. We are using the integration with JIRA but I don't see a way to get this information.

  • Avatar
    Emilio Méndez

    Great topic, not only in content but in form as well; exactly what I was looking for !!  Thank you Charles & Zendesk Team !!

  • Avatar
    Emilio Méndez

    Hi Don:

    Basic reporting might be limited, but you can try "Insights", it's definitely a whole different thing; the only thing is that it depends on the plan you have.

    Hope that works for you !!

    Regards,

  • Avatar
    Charles Nadeau

    Hi Don,

    To learn how to use the API to export lots of data to Excel, see the companion tutorial:

  • Avatar
    Alex Taitague (Edited )

    Thanks. I had trouble at the pickle part...I run my script with the API call and serializing the results, but when I go to run the script again (API commented out) I get the message that the pickle file cannot be found. I can't find any file created after the script run. (within any script run, I can write and read back the serialized data -- it just doesn't persist outside of the script run).

    Any ideas?

     

     

  • Avatar
    Charles Nadeau

    Hi Alex,

    I ran this script again to test if any Python libraries had been updated since I wrote it. Running Python 3.6, I had no issues serializing the data into a separate file named 'my_serialized_data_file'. The file appears in the same folder as my Python script.

    Maybe you're in Windows and the OS is confused by the lack of a file extension? Try adding ".p" to the Pickle file, as follows:

    topic_data = {'posts': topic_posts, 'users': user_list}
    with open('my_serialized_data_file.p', mode='wb') as f:
    pickle.dump(topic_data, f)

     

Please sign in to leave a comment.

Powered by Zendesk