Last active
October 20, 2020 14:52
-
-
Save chucknado/3d26957f348924bf9602 to your computer and use it in GitHub Desktop.
A Python script for the article "Zendesk REST API tutorial: Searching" at https://support.zendesk.com/hc/en-us/articles/203691406
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from urllib.parse import urlencode | |
import requests | |
credentials = 'your_zendesk_email', 'your_zendesk_password' | |
session = requests.Session() | |
session.auth = credentials | |
params = { | |
'query': 'type:ticket status:open', | |
'sort_by': 'created_at', | |
'sort_order': 'asc' | |
} | |
url = 'https://your_subdomain.zendesk.com/api/v2/search.json?' + urlencode(params) | |
response = session.get(url) | |
if response.status_code != 200: | |
print('Status:', response.status_code, 'Problem with the request. Exiting.') | |
exit() | |
# Print the subject of each ticket in the results | |
data = response.json() | |
for result in data['results']: | |
print(result['subject']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment