Skip to content

Instantly share code, notes, and snippets.

@dpawluk
Created January 15, 2014 19:57
Show Gist options
  • Save dpawluk/8443329 to your computer and use it in GitHub Desktop.
Save dpawluk/8443329 to your computer and use it in GitHub Desktop.
Regular REST api example using python
import requests
payload = '{"ticket":{"requester":{"name":"Dan Pawluk", "email":"daniel.pawluk@me.com"}, "subject":"My printer is on fire!", "comment": { "body": "I want thousands of tickets" }}}'
s = requests.Session()
s.headers.update({'Content-Type': 'application/json'})
s.auth = ('{username}','{password}')
#r = s.post("http://requestb.in/1hjs6jw1", data=payload)
for x in range (0,11999):
try:
r = s.post("https://sandedboxy.zendesk.com/api/v2/imports/tickets.json", data=payload)
print("finished with request number:" + str(x))
except requests.exceptions.ConnectionError as e:
print("There was a connection error: %s" % (e))
except requests.exceptions.Timeout as e:
print("There was a timeout!!!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment