Skip to content

Instantly share code, notes, and snippets.

@crobrock
Created October 10, 2020 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crobrock/f44bf613e548d2ed1ebd84edae0f3947 to your computer and use it in GitHub Desktop.
Save crobrock/f44bf613e548d2ed1ebd84edae0f3947 to your computer and use it in GitHub Desktop.
Return Count of Zendesk Ticket View
import requests
from base64 import b64encode
ZENDESK_SUBDOMAIN = 'YOUR_SUBDOMAIN'
ZENDESK_VIEW_ID = 'YOUR_ZENDESK_VIEW_ID'
ZENDESK_EMAIL = 'YOUR_ZENDESK_EMAIL'
ZENDESK_API_TOKEN = 'YOUR_ZENDESK_API_TOKEN'
url = f'https://{ZENDESK_SUBDOMAIN}.zendesk.com/api/v2/views/{ZENDESK_VIEW_ID}/count.json'
auth = f'{ZENDESK_EMAIL}/token:{ZENDESK_API_TOKEN}'
auth_encoded = b64encode(bytes(auth, 'utf-8')).decode('ascii')
headers = {
'Content-Type': 'application/json',
'Authorization': f'Basic {auth_encoded}'
}
data = requests.get(url, headers=headers).json()
view_count = data['view_count']['value']
output = {'view_count': view_count}
@duongchiu383
Copy link

How this works

@duongchiu383
Copy link

How can I meet my friends and family

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment