Sample API requests using Python

Prerequisites:

  1. API doc - Read here

  2. How to get API key and Auth Code - Read here

Examples:

Read Tickets

url = https://<subdomain>.happyfox.com/api/1.1/json/tickets/
auth = ('<apli_key>','<auth_code>')
res = requests.get(url,auth=auth)

Create a New ticket

import requests
import json
url = https://<subdomain>.happyfox.com/api/1.1/json/tickets/
auth = ('<apli_key>','<auth_code>')
headers = {'Content-Type': 'application/json'}
payload = {'subject': 'test subject', 'text': 'This is a test ticket', 'category': 1, 'priority': 2, 'email': 'test@example.com', 'name': 'Test Customer'}
res = requests.post(url,auth=auth,data=json.dumps(payload), headers=headers)

  • 836
  • 26-Mar-2019
  • 476 Views